C SOURCES:
C    Erich Goll, Matthias Ernst, Franzeska Moegle-Hofacker, and Hermann Stoll. 
C    Development and assessment of a short-range meta-GGA functional.
C    The Journal of Chemical Physics, 130(23):234112, jun 2009.



C*****************************************************************************
      pure subroutine ESRX_TPSS_GWS_ERF_case_1(rho_a, gamma_aa, tau_a, m
     &u, Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13
      Ea = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = mu*rho_a**(-0.333333333333333d0)
      x2 = 0.0472353356922751d0
      x3 = 0.217336917462899d0
      x4 = mu**2*rho_a**(-0.666666666666667d0)*x3
      x5 = gamma_aa*rho_a**(-2.66666666666667d0)*x3
      x6 = gamma_aa**2
      x7 = rho_a**(-5.33333333333333d0)*x2
      x8 = 1/(rho_a**2*tau_a**2)
      x9 = x6*x8
      x10 = 0.050475572023115d0*x5
      x11 = -1.0d0 + 8.0d0*rho_a*tau_a/gamma_aa
      x12 = x11*x5
      x13 = (x10*x11*(0.126188930057787d0*x12 - 1.0d0) + 1.0d0)**(-0.5d0
     &)
      Ea = -x0*(1.8610514726982d0*(0.804d0/(0.0206714418186455d0*x5 + 1.
     &0d0) - 0.804d0/(1.0d0 + (1.86977850568311d-6*gamma_aa**3*rho_a**(-
     &8.0d0 ) - 1.24378109452736d0*gamma_aa*sqrt(0.00286625629244325d0*x
     &7 + 0.0028125d0*x8)*(x13*(0.0102353243269094d0*x12 - 0.08111111111
     &11111d0) + 0.00909806606836394d0*x5) + 0.0941708433267071d0*x5*(0.
     &02485875d0*x9/(0.015625d0*x9 + 1.0d0) **2 + 0.123456790123457d0) +
     & 0.000135164574498753d0*x6*x7 + 0.0021416494625995d0*x9 + 0.089675
     &0813832074d0*(x10 + x13*( 0.0567850185260044d0*x12 - 0.45d0))**2)/
     &(0.0938662444277524d0*x5 + 1.0d0)**2))*exp(-1.9241736577956332d0*x
     &1) + 3.35733685674755d0 - 1.49628538404935d0/(0.239205142311446d0*
     &x5*(5.45136177849642d0* x4 - 7.0d0)*exp(-1.4385538026587772d0*x4)/
     &(4.95289087334194d0*mu **4*x2/x0 + 49.1113297378199d0*x1 - 49.0622
     &560064678d0*x4 - 81.0d0) + 1.0d0))
      end subroutine


C*****************************************************************************
      pure subroutine ESRX_TPSS_GWS_ERF_case_2_1(rho_a, gamma_aa, tau_a,
     & mu, Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21
      Ea = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = rho_a**0.333333333333333d0
      x2 = 1d0/x1
      x3 = 0.0472353356922751d0
      x4 = 4.60115111447049d0
      x5 = 1d0/x4
      x6 = mu**2
      x7 = rho_a**0.666666666666667d0
      x8 = x5*x6/x7
      x9 = gamma_aa*rho_a**(-2.66666666666667d0)*x5
      x10 = 2.14502939711103d0
      x11 = x2/x10
      x12 = mu*x11
      x13 = 0.00844343197019482d0*1d0/rho_a
      x14 = gamma_aa**2
      x15 = rho_a**(-5.33333333333333d0)*x3
      x16 = 1/(rho_a**2*tau_a**2)
      x17 = x14*x16
      x18 = 0.050475572023115d0*x9
      x19 = -1.0d0 + 8.0d0*rho_a*tau_a/gamma_aa
      x20 = x19*x9
      x21 = (x18*x19*(0.126188930057787d0*x20 - 1.0d0) + 1.0d0)**(-0.5d0
     &)
      Ea = -x0*(-4.9628039271952d0*(1.804d0 - 0.804d0/(0.239205142311446
     &d0*x9*( 5.45136177849642d0*x8 - 7.0d0)*exp(-1.4385538026587772d0*x
     &8)/( 4.95289087334194d0*mu**4*x3/x0 + 49.1113297378199d0*mu*x2 - 4
     &9.0622560064678d0*x8 - 81.0d0) + 1.0d0))*(0.275160604074552d0* x12
     &*(mu**3*x13 + mu*(0.550321208149104d0*x11 - x13*x6)*exp( -3.301927
     &2488946267d0*x4*x7/x6) - 0.825481812223657d0*x12 + 1.7724538509055
     &2d0*erf(1.8171205928321397d0*x1*x10/mu)) - 0.375d0 ) + 1.861051472
     &6982d0*(0.804d0/(0.0206714418186455d0*x9 + 1.0d0) - 0.804d0/(1.0d0
     & + (1.86977850568311d-6*gamma_aa**3*rho_a**( -8.0d0) - 1.243781094
     &52736d0*gamma_aa*sqrt(0.00286625629244325d0* x15 + 0.0028125d0*x16
     &)*(x21*(0.0102353243269094d0*x20 - 0.0811111111111111d0) + 0.00909
     &806606836394d0*x9) + 0.000135164574498753d0*x14*x15 + 0.0021416494
     &625995d0*x17 + 0.0941708433267071d0*x9*(0.02485875d0*x17/(0.015625
     &d0*x17 + 1.0d0 )**2 + 0.123456790123457d0) + 0.0896750813832074d0*
     &(x18 + x21*( 0.0567850185260044d0*x20 - 0.45d0))**2)/(0.0938662444
     &277524d0*x9 + 1.0d0)**2))*exp(-4.1274090611182839d0*x12))
      end subroutine


C*****************************************************************************
      pure subroutine ESRX_TPSS_GWS_ERF_case_2_2(rho_a, gamma_aa, tau_a,
     & mu, Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22
      Ea = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = mu**2
      x2 = 1d0/x1
      x3 = 4.60115111447049d0
      x4 = rho_a**0.666666666666667d0
      x5 = x3*x4
      x6 = 21.1705915781930d0
      x7 = 97.4090910340024d0
      x8 = 1d0/x3
      x9 = gamma_aa*rho_a**(-2.66666666666667d0)*x8
      x10 = 2.14502939711103d0
      x11 = rho_a**0.333333333333333d0
      x12 = 1/(x10*x11)
      x13 = mu*x12
      x14 = 0.00844343197019482d0*1d0/rho_a
      x15 = gamma_aa**2
      x16 = rho_a**(-5.33333333333333d0)/x6
      x17 = 1/(rho_a**2*tau_a**2)
      x18 = x15*x17
      x19 = 0.050475572023115d0*x9
      x20 = -1.0d0 + 8.0d0*rho_a*tau_a/gamma_aa
      x21 = x20*x9
      x22 = (x19*x20*(0.126188930057787d0*x21 - 1.0d0) + 1.0d0)**(-0.5d0
     &)
      Ea = -x0*(-4.9628039271952d0*(1.804d0 - 0.804d0/(-0.23920514231144
     &6d0*x2*x9*( 0.010095114404623d0*x0*x2*x6 - 0.183440402716368d0*x5 
     &+ 0.147857142857143d0*rho_a**2.0d0*x7/mu**4)*exp( -1.4385538026587
     &772d0*x1*x8/x4) + 1.0d0))*(0.275160604074552d0* x13*(mu**3*x14 + m
     &u*(-x1*x14 + 0.550321208149104d0*x12)*exp( -3.3019272488946267d0*x
     &2*x5) - 0.825481812223657d0*x13 + 1.77245385090552d0*erf(1.8171205
     &928321397d0*x10*x11/mu)) - 0.375d0) + 1.8610514726982d0*(0.804d0/(
     &0.0206714418186455d0*x9 + 1.0d0) - 0.804d0/(1.0d0 + (0.00018213342
     &4673508d0*gamma_aa**3* rho_a**(-8.0d0)/x7 - 1.24378109452736d0*gam
     &ma_aa*sqrt( 0.00286625629244325d0*x16 + 0.0028125d0*x17)*(x22*( 0.
     &0102353243269094d0*x21 - 0.0811111111111111d0) + 0.009098066068363
     &94d0*x9) + 0.000135164574498753d0*x15*x16 + 0.0021416494625995d0*x
     &18 + 0.0941708433267071d0*x9*(0.02485875d0* x18/(0.015625d0*x18 + 
     &1.0d0)**2 + 0.123456790123457d0) + 0.0896750813832074d0*(x19 + x22
     &*(0.0567850185260044d0*x21 - 0.45d0))**2)/(0.0938662444277524d0*x9
     & + 1.0d0)**2))*exp( -4.1274090611182839d0*x13))
      end subroutine


C*****************************************************************************
      pure subroutine ESRX_TPSS_GWS_ERF_case_2_3(rho_a, gamma_aa, tau_a,
     & mu, Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6
      Ea = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 2.14502939711103d0
      x2 = rho_a**0.333333333333333d0
      x3 = 1/(x1*x2)
      x4 = mu*x3
      x5 = 0.00844343197019482d0*1d0/rho_a
      x6 = erf(1.8171205928321397d0*x1*x2/mu)
      x7 = 4.60115111447049d0
      x8 = mu**2
      x9 = 1d0/x8
      x10 = rho_a**0.666666666666667d0
      x11 = 3.30192724889463d0*x10*x7*x9
      x12 = 1d0/x7
      x13 = x12*x8/x10
      x14 = 0.0472353356922751d0
      x15 = exp(x11)
      x16 = mu**4*x14*(x15 - 1.0d0)/x0
      x17 = 3.0d0*x15
      x18 = gamma_aa*rho_a**(-2.66666666666667d0)*x12
      x19 = gamma_aa**2
      x20 = rho_a**(-5.33333333333333d0)*x14
      x21 = 1/(rho_a**2*tau_a**2)
      x22 = x19*x21
      x23 = 0.050475572023115d0*x18
      x24 = -1.0d0 + 8.0d0*rho_a*tau_a/gamma_aa
      x25 = x18*x24
      x26 = (x23*x24*(0.126188930057787d0*x25 - 1.0d0) + 1.0d0)**(-0.5d0
     &)
      Ea = -x0*(-4.9628039271952d0*(1.804d0 - 0.804d0/(-3.15935190989552
     &d0*gamma_aa *rho_a**(-2.0d0)*x9*(0.00280419844572861d0*x13*(7.0d0*
     &x15 + 11.0d0) - 0.015286700226364d0*x16 + 0.0185185185185185d0)*ex
     &p( -1.4385538026587772d0*x13)/(-0.60570686427738d0*x13*(x17 - 2.0d
     &0 ) + 3.90167577847542d0*x15*x4*x6 + 0.183440402716368d0*x16 - x17
     & ) + 1.0d0))*(0.275160604074552d0*x4*(mu**3*x5 + mu*( 0.5503212081
     &49104d0*x3 - x5*x8)*exp(-x11) - 0.825481812223657d0* x4 + 1.772453
     &85090552d0*x6) - 0.375d0) + 1.8610514726982d0*( 0.804d0/(0.0206714
     &418186455d0*x18 + 1.0d0) - 0.804d0/(1.0d0 + ( 1.86977850568311d-6*
     &gamma_aa**3*rho_a**(-8.0d0) - 1.24378109452736d0*gamma_aa*(0.00909
     &806606836394d0*x18 + x26*( 0.0102353243269094d0*x25 - 0.0811111111
     &111111d0))*sqrt( 0.00286625629244325d0*x20 + 0.0028125d0*x21) + 0.
     &0941708433267071d0*x18*(0.02485875d0*x22/(0.015625d0*x22 + 1.0d0)*
     &*2 + 0.123456790123457d0) + 0.000135164574498753d0*x19*x20 + 0.002
     &1416494625995d0*x22 + 0.0896750813832074d0*(x23 + x26*( 0.05678501
     &85260044d0*x25 - 0.45d0))**2)/(0.0938662444277524d0*x18 + 1.0d0)**
     &2))*exp(-4.1274090611182839d0*x4))
      end subroutine


C*****************************************************************************
      pure subroutine ESRX_TPSS_GWS_ERF_case_3(rho_a, gamma_aa, tau_a, m
     &u, Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16
      Ea = 0.0d0
      x0 = mu**2
      x1 = 1d0/x0
      x2 = 4.60115111447049d0
      x3 = rho_a**0.666666666666667d0
      x4 = 21.1705915781930d0
      x5 = 97.4090910340024d0
      x6 = 1d0/x2
      x7 = gamma_aa*rho_a**(-2.66666666666667d0)*x6
      x8 = rho_a**0.333333333333333d0
      x9 = gamma_aa**2
      x10 = rho_a**(-5.33333333333333d0)/x4
      x11 = 1/(rho_a**2*tau_a**2)
      x12 = x11*x9
      x13 = 0.050475572023115d0*x7
      x14 = -1.0d0 + 8.0d0*rho_a*tau_a/gamma_aa
      x15 = x14*x7
      x16 = (x13*x14*(0.126188930057787d0*x15 - 1.0d0) + 1.0d0)**(-0.5d0
     &)
      Ea = -rho_a*(3.14159265358979d0*rho_a**1.0d0*x1*(1.804d0 - 0.804d0
     &/( -0.239205142311446d0*x1*x7*(0.010095114404623d0*rho_a** 1.33333
     &333333333d0*x1*x4 - 0.183440402716368d0*x2*x3 + 0.147857142857143d
     &0*rho_a**2.0d0*x5/mu**4)*exp( -1.4385538026587772d0*x0*x6/x3) + 1.
     &0d0)) + 1.8610514726982d0*x8* (0.804d0/(0.0206714418186455d0*x7 + 
     &1.0d0) - 0.804d0/(1.0d0 + ( 0.000182133424673508d0*gamma_aa**3*rho
     &_a**(-8.0d0)/x5 - 1.24378109452736d0*gamma_aa*sqrt(0.0028662562924
     &4325d0*x10 + 0.0028125d0*x11)*(x16*(0.0102353243269094d0*x15 - 0.0
     &811111111111111d0) + 0.00909806606836394d0*x7) + 0.000135164574498
     &753d0*x10*x9 + 0.0021416494625995d0*x12 + 0.0941708433267071d0*x7*
     &(0.02485875d0*x12/(0.015625d0*x12 + 1.0d0 )**2 + 0.123456790123457
     &d0) + 0.0896750813832074d0*(x13 + x16*( 0.0567850185260044d0*x15 -
     & 0.45d0))**2)/(0.0938662444277524d0*x7 + 1.0d0)**2))*exp(-1.924173
     &6577956332d0*mu/x8))
      end subroutine


C*****************************************************************************
      pure subroutine D1ESRX_TPSS_GWS_ERF_case_1(rho_a, gamma_aa, tau_a,
     & mu, Ea, d1Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = rho_a**(-2.66666666666667d0)
      x3 = 0.217336917462899d0
      x4 = x2*x3
      x5 = gamma_aa*x4
      x6 = 0.826307487110758d0
      x7 = rho_a**0.333333333333333d0
      x8 = mu/x7
      x9 = 0.0472353356922751d0
      x10 = 1d0/x0
      x11 = mu**2
      x12 = rho_a**(-0.666666666666667d0)*x11*x3
      x13 = 1d0/(4.95289087334194d0*mu**4*x10*x9 - 49.0622560064678d0*x1
     &2 + 59.4346904801033d0*x6*x8 - 81.0d0)
      x14 = x13*exp(-1.4385538026587772d0*x12)
      x15 = 5.45136177849642d0*x12 - 7.0d0
      x16 = 0.239205142311446d0*x15
      x17 = x14*x16*x5 + 1.0d0
      x18 = x1*(1.804d0 - 0.804d0/x17)
      x19 = 2.72568088924821d0*x18
      x20 = exp(-1.9241736577956332d0*x8)
      x21 = 0.0206714418186455d0*x5 + 1.0d0
      x22 = 0.804d0/x21
      x23 = 0.0938662444277524d0*x5 + 1.0d0
      x24 = x23**(-2)
      x25 = 0.050475572023115d0*x5
      x26 = tau_a/gamma_aa
      x27 = 8.0d0*rho_a*x26
      x28 = x27 - 1.0d0
      x29 = x28*x5
      x30 = 0.0567850185260044d0*x29 - 0.45d0
      x31 = 0.126188930057787d0*x28
      x32 = x31*x5 - 1.0d0
      x33 = x28*x32
      x34 = x25*x33 + 1.0d0
      x35 = x34**(-0.5d0)
      x36 = x25 + x30*x35
      x37 = x36**2
      x38 = 0.00909806606836394d0*x4
      x39 = gamma_aa*x38
      x40 = x35*(0.0102353243269094d0*x29 - 0.0811111111111111d0) + x39
      x41 = rho_a**(-5.33333333333333d0)*x9
      x42 = rho_a**(-2)
      x43 = tau_a**(-2)
      x44 = 0.0028125d0*x43
      x45 = sqrt(0.00286625629244325d0*x41 + x42*x44)
      x46 = gamma_aa*x45
      x47 = x40*x46
      x48 = gamma_aa**2
      x49 = x41*x48
      x50 = rho_a**(-8.0d0)
      x51 = 0.0102659822546843d0
      x52 = gamma_aa**3
      x53 = x51*x52
      x54 = x50*x53
      x55 = x43*x48
      x56 = x42*x55
      x57 = 0.015625d0*x56 + 1.0d0
      x58 = x57**(-2)
      x59 = 0.02485875d0*x56*x58 + 0.123456790123457d0
      x60 = 0.0941708433267071d0*x59
      x61 = 0.000135164574498753d0*x49 + x5*x60 + 0.000182133424673508d0
     &*x54 + 0.0021416494625995d0*x56
      x62 = x24*(0.0896750813832074d0*x37 - 1.24378109452736d0*x47 + x61
     &) + 1.0d0
      x63 = -0.804d0/x62
      x64 = x20*(x22 + x63)
      x65 = 0.682784063255296d0
      x66 = 2.72568088924821d0*x65
      x67 = x64*x66
      x68 = rho_a**(-0.666666666666667d0)
      x69 = rho_a**(-4.33333333333333d0)*x9
      x70 = x11*x69
      x71 = rho_a**(-3.66666666666667d0)
      x72 = rho_a**(-1.66666666666667d0)
      x73 = x3*x72
      x74 = rho_a**(-2.33333333333333d0)
      x75 = x14/x17**2
      x76 = 0.148394183600699d0
      x77 = x76/x21**2
      x78 = 0.90856029641607d0*x65*x68
      x79 = rho_a**(-6.33333333333333d0)*x9
      x80 = rho_a**(-3)
      x81 = gamma_aa*x71
      x82 = x3*x81
      x83 = 0.001553671875d0*x56/x57 - 0.0497175d0
      x84 = 0.0941708433267071d0*x3*x58*x83
      x85 = 1d0/x45
      x86 = 1d0/x23
      x87 = 0.000108672317896998d0*x49 + 0.0757133580346725d0*x5*x59 + 0
     &.0001464352734375d0*x54 + 0.00172188616792999d0*x56
      x88 = tau_a*x2
      x89 = x28*x81
      x90 = x35*(0.454280148208035d0*x88 - 0.151426716069345d0*x89)
      x91 = 0.180246913580247d0*x3
      x92 = x3*x32
      x93 = 0.0252377860115575d0*gamma_aa*x2*x28*x9
      x94 = x30*x34**(-1.5d0)*(-0.20190228809246d0*x88*x92 + 0.067300762
     &6974867d0* x89*x92 - x93*(1.0095114404623d0*x88 - 0.33650381348743
     &3d0*x89))
      x95 = 1.24378109452736d0*x46
      x96 = 2.0d0*x3
      x97 = x24*x65*x7
      x98 = -x27 + 1.0d0
      x99 = 0.0567850185260044d0*x98
      x100 = x5*x99 + 0.45d0
      x101 = x5*x98
      x102 = 0.126188930057787d0*x101 + 1.0d0
      x103 = x102*x25*x98 + 1.0d0
      x104 = x103**(-0.5d0)
      x105 = -x100*x104 + x25
      x106 = x105**2
      x107 = -x104*(0.0102353243269094d0*x101 + 0.0811111111111111d0) + 
     &x39
      x108 = 1.24378109452736d0*x107
      x109 = (x24*(0.0896750813832074d0*x106 - x108*x46 + x61) + 1.0d0)*
     &*(-2)
      x110 = gamma_aa*x42
      x111 = rho_a**(-4.66666666666667d0)
      x112 = x26*x72
      x113 = x104*(0.454280148208035d0*x112 + x2*x99)
      x114 = 0.20190228809246d0*x73
      x115 = x103**(-1.5d0)*(-x114*x26*x32 + 0.0252377860115575d0*x33*x4
     & + x93*( -1.0095114404623d0*x112 + x2*x31))
      x116 = 0.180246913580247d0*x100
      x117 = 2.0d0*x100
      x118 = tau_a**(-3)
      x119 = (0.0254778337106067d0*gamma_aa*x69*x98 + x102*x114)/x103
      Ea = -x0*(x19 + x67)
      d1Ea(1) = -rho_a*(2.19144743495556d0*gamma_aa*x1*x7*x75*(mu*x13*x1
     &6*x4*( 6.60385449778925d0*mu**3*x74*x9 - 32.7081706709785d0*mu*x73
     & + 19.8115634933678d0*x10*x6) - 0.637880379497189d0*x15*x3*x71 + 0
     &.229406311391776d0*x15*x70 - 0.869329180010942d0*x70) + 1.19366207
     &318922d0*mu*1d0/rho_a*x64 + 0.90856029641607d0*x18*x68 + x20*(0.12
     &080100840081d0*gamma_aa*rho_a**(-3.33333333333333d0)* x77 - x78*(-
     &x22 + 1.804d0) + x78*(x63 + 1.804d0) + 2.19144743495556d0*x97*(1.2
     &4378109452736d0*gamma_aa*x40*x85*(x44* x80 + 0.00764335011318201d0
     &*x79) - 0.00145706739738806d0*rho_a**( -9.0d0)*x53 + rho_a**(-5.66
     &666666666667d0)*x43*x52*x84 + 0.0896750813832074d0*x36*(-0.2692030
     &50789947d0*x82 + x90*x96 + 2.0d0*x94) - 0.000720877730660018d0*x48
     &*x79 - 0.00428329892519899d0*x55*x80 - 0.251122248871219d0*x59*x82
     & + 0.622661654578789d0*x82*x86*(0.0720987654320988d0*x37 - x47 + x
     &87 ) - x95*(-0.0242615095156372d0*x82 + x90*x91 + 0.18024691358024
     &7d0*x94))/x62**2)) - x19*x7 - x67*x7
      d1Ea(2) = -rho_a*(0.524205495546598d0*x15*x74*x75*x76 - 2.0d0*x20*
     &( 1.09572371747778d0*x109*x97*(-0.000270329148997507d0*gamma_aa*x4
     &1 - 0.0896750813832074d0*x105*(-x113*x96 + x115*x117 + 0.100951144
     &04623d0*x4) + x108*x45 - 0.00428329892519899d0*x110* x43 + x111*x5
     &5*x84 - x4*x60 + 0.233498120467046d0*x4*x86*( 0.0720987654320988d0
     &*x106 - x107*x46 + x87) - 0.000546400274020523d0*x48*x50*x51 + x95
     &*(-x113*x91 + x115*x116 + x38)) + 0.0226501890751519d0*x74*x77))
      d1Ea(3) = -x0*x109*x20*x24*x66*(0.0720987654320988d0*x104*x105*(-x
     &117*x119 + 0.90856029641607d0*x73) - x104*x46*(-x116*x119 + 0.0818
     &825946152754d0*x73) + 0.0028125d0*x107*x110*x118*x85 + 0.075713358
     &0346725d0*x111*x118*x3*x52*x58*x83 - 0.00344377233585999d0*x118*x4
     &2*x48)
      end subroutine


C*****************************************************************************
      pure subroutine D1ESRX_TPSS_GWS_ERF_case_2_1(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = rho_a**(-2.66666666666667d0)
      x2 = 4.60115111447049d0
      x3 = 1d0/x2
      x4 = x1*x3
      x5 = gamma_aa*x4
      x6 = 0.826307487110758d0
      x7 = rho_a**0.333333333333333d0
      x8 = 1d0/x7
      x9 = 0.0472353356922751d0
      x10 = 1d0/x0
      x11 = mu**2
      x12 = rho_a**0.666666666666667d0
      x13 = x11*x3/x12
      x14 = 1d0/(4.95289087334194d0*mu**4*x10*x9 + 59.4346904801033d0*mu
     &*x6*x8 - 49.0622560064678d0*x13 - 81.0d0)
      x15 = x14*exp(-1.4385538026587772d0*x13)
      x16 = 5.45136177849642d0*x13 - 7.0d0
      x17 = 0.239205142311446d0*x16
      x18 = x15*x17*x5 + 1.0d0
      x19 = 1.804d0 - 0.804d0/x18
      x20 = 7.26848237132856d0*x19
      x21 = 0.682784063255296d0
      x22 = 2.14502939711103d0
      x23 = 1d0/x22
      x24 = x23*x8
      x25 = 0.550321208149104d0*x24
      x26 = 1d0/rho_a
      x27 = 0.00844343197019481d0
      x28 = x26*x27
      x29 = x11*x28
      x30 = exp(-3.3019272488946267d0*x12*x2/x11)
      x31 = mu*x30
      x32 = 1d0/mu
      x33 = x22*x32
      x34 = mu**3
      x35 = mu*x24
      x36 = x28*x34 - 0.825481812223657d0*x35 + 1.77245385090552d0*erf( 
     &1.8171205928321397d0*x33*x7)
      x37 = 0.275160604074552d0*x35
      x38 = x37*(x31*(x25 - x29) + x36) - 0.375d0
      x39 = x21*x38
      x40 = exp(-4.1274090611182839d0*x35)
      x41 = 0.0206714418186455d0*x5 + 1.0d0
      x42 = 0.804d0/x41
      x43 = 0.0938662444277524d0*x5 + 1.0d0
      x44 = x43**(-2)
      x45 = 0.050475572023115d0*x5
      x46 = tau_a/gamma_aa
      x47 = 8.0d0*rho_a*x46
      x48 = x47 - 1.0d0
      x49 = x48*x5
      x50 = 0.0567850185260044d0*x49 - 0.45d0
      x51 = 0.126188930057787d0*x48
      x52 = x5*x51 - 1.0d0
      x53 = x48*x52
      x54 = x45*x53 + 1.0d0
      x55 = x54**(-0.5d0)
      x56 = x45 + x50*x55
      x57 = x56**2
      x58 = 0.00909806606836394d0*x4
      x59 = gamma_aa*x58
      x60 = x55*(0.0102353243269094d0*x49 - 0.0811111111111111d0) + x59
      x61 = rho_a**(-5.33333333333333d0)*x9
      x62 = rho_a**(-2)
      x63 = tau_a**(-2)
      x64 = 0.0028125d0*x63
      x65 = sqrt(0.00286625629244325d0*x61 + x62*x64)
      x66 = gamma_aa*x65
      x67 = x60*x66
      x68 = gamma_aa**2
      x69 = x61*x68
      x70 = rho_a**(-8.0d0)
      x71 = 0.0102659822546843d0
      x72 = gamma_aa**3
      x73 = x71*x72
      x74 = x70*x73
      x75 = x63*x68
      x76 = x62*x75
      x77 = 0.015625d0*x76 + 1.0d0
      x78 = x77**(-2)
      x79 = 0.02485875d0*x76*x78 + 0.123456790123457d0
      x80 = 0.0941708433267071d0*x79
      x81 = x5*x80 + 0.000135164574498753d0*x69 + 0.000182133424673508d0
     &*x74 + 0.0021416494625995d0*x76
      x82 = x44*(0.0896750813832074d0*x57 - 1.24378109452736d0*x67 + x81
     &) + 1.0d0
      x83 = -0.804d0/x82
      x84 = x40*(x42 + x83)
      x85 = 0.682784063255296d0
      x86 = 2.72568088924821d0*x85
      x87 = -x25 + x29
      x88 = -x31*x87 + x36
      x89 = x20*x7
      x90 = -x47 + 1.0d0
      x91 = 0.0567850185260044d0*x90
      x92 = x5*x91 + 0.45d0
      x93 = x5*x90
      x94 = 0.126188930057787d0*x93 + 1.0d0
      x95 = x45*x90*x94 + 1.0d0
      x96 = x95**(-0.5d0)
      x97 = x45 - x92*x96
      x98 = x97**2
      x99 = x59 - x96*(0.0102353243269094d0*x93 + 0.0811111111111111d0)
      x100 = 1.24378109452736d0*x99
      x101 = x44*(-x100*x66 + x81 + 0.0896750813832074d0*x98) + 1.0d0
      x102 = x40*x86
      x103 = rho_a**(-0.666666666666667d0)
      x104 = x10*x23
      x105 = rho_a**(-2.0d0)*x27
      x106 = 0.318309886183791d0*mu
      x107 = rho_a**(-4.33333333333333d0)*x9
      x108 = x107*x11
      x109 = rho_a**(-3.66666666666667d0)
      x110 = rho_a**(-1.66666666666667d0)
      x111 = x110*x3
      x112 = rho_a**(-2.33333333333333d0)
      x113 = x15/x18**2
      x114 = 0.148394183600699d0
      x115 = x114/x41**2
      x116 = 0.90856029641607d0*x103*x85
      x117 = rho_a**(-6.33333333333333d0)*x9
      x118 = rho_a**(-3)
      x119 = gamma_aa*x109
      x120 = x119*x3
      x121 = 0.001553671875d0*x76/x77 - 0.0497175d0
      x122 = 0.0941708433267071d0*x121*x3*x78
      x123 = 1d0/x65
      x124 = 1d0/x43
      x125 = 0.0757133580346725d0*x5*x79 + 0.000108672317896998d0*x69 + 
     &0.0001464352734375d0*x74 + 0.00172188616792999d0*x76
      x126 = tau_a*x1
      x127 = x119*x48
      x128 = x55*(0.454280148208035d0*x126 - 0.151426716069345d0*x127)
      x129 = 0.180246913580247d0*x3
      x130 = x3*x52
      x131 = 0.0252377860115575d0*gamma_aa*x1*x48*x9
      x132 = x50*x54**(-1.5d0)*(-0.20190228809246d0*x126*x130 + 0.067300
     &7626974867d0* x127*x130 - x131*(1.0095114404623d0*x126 - 0.3365038
     &13487433d0* x127))
      x133 = 1.24378109452736d0*x66
      x134 = 2.0d0*x3
      x135 = x44*x7*x85
      x136 = x101**(-2)
      x137 = gamma_aa*x62
      x138 = rho_a**(-4.66666666666667d0)
      x139 = x110*x46
      x140 = x96*(x1*x91 + 0.454280148208035d0*x139)
      x141 = 0.20190228809246d0*x111
      x142 = x95**(-1.5d0)*(x131*(x1*x51 - 1.0095114404623d0*x139) - x14
     &1*x46*x52 + 0.0252377860115575d0*x4*x53)
      x143 = 0.180246913580247d0*x92
      x144 = 2.0d0*x92
      x145 = tau_a**(-3)
      x146 = (0.0254778337106067d0*gamma_aa*x107*x90 + x141*x94)/x95
      Ea = -x0*(-x20*x39 + x84*x86)
      d1Ea(1) = -rho_a*(-5.84385982654816d0*gamma_aa*x113*x39*x7*(mu*x14
     &*x17*x4*( -32.7081706709785d0*mu*x111 + 19.8115634933678d0*x10*x6 
     &+ 6.60385449778925d0*x112*x34*x9) + 0.229406311391776d0*x108*x16 -
     & 0.869329180010942d0*x108 - 0.637880379497189d0*x109*x16*x3) - 2.4
     &2282745710952d0*x103*x19*x39 + 3.75d0*x106*x26*x84 + x106*x89* (0.
     &0917202013581841d0*x10*x88 - 0.275160604074552d0*x8*( 0.2751606040
     &74552d0*mu*x104 + 2.20128483259642d0*rho_a**( -0.333333333333333d0
     &)*x2*x30*x32*x87 + 1.21141372855476d0*x103* x30*x33 - x105*x34 + x
     &31*(-0.183440402716368d0*x104 + x105*x11 ))) + x40*(0.120801008400
     &81d0*gamma_aa*rho_a**( -3.33333333333333d0)*x115 - x116*(-x42 + 1.
     &804d0) + x116*(x83 + 1.804d0) + 2.19144743495556d0*x135*(1.2437810
     &9452736d0*gamma_aa* x123*x60*(0.00764335011318201d0*x117 + x118*x6
     &4) - 0.00145706739738806d0*rho_a**(-9.0d0)*x73 + rho_a**( -5.66666
     &666666667d0)*x122*x63*x72 - 0.000720877730660018d0*x117* x68 - 0.0
     &0428329892519899d0*x118*x75 + 0.622661654578789d0*x120* x124*(x125
     & + 0.0720987654320988d0*x57 - x67) - 0.251122248871219d0*x120*x79 
     &- x133*(-0.0242615095156372d0*x120 + x128*x129 + 0.180246913580247
     &d0*x132) + 0.0896750813832074d0*x56* (-0.269203050789947d0*x120 + 
     &x128*x134 + 2.0d0*x132))/x82**2)) - x102*x7*(x42 - 0.804d0/x101) +
     & x21*x89*(x37*x88 - 0.375d0)
      d1Ea(2) = rho_a*(1.39788132145759d0*x112*x113*x114*x16*x38 + 2.0d0
     &*x40*( 0.0226501890751519d0*x112*x115 + 1.09572371747778d0*x135*x1
     &36*( -0.000270329148997507d0*gamma_aa*x61 + x100*x65 + x122*x138*x
     &75 + 0.233498120467046d0*x124*x4*(x125 - x66*x99 + 0.0720987654320
     &988d0*x98) + x133*(-x129*x140 + x142*x143 + x58) - 0.0042832989251
     &9899d0*x137*x63 - x4*x80 - 0.000546400274020523d0* x68*x70*x71 - 0
     &.0896750813832074d0*x97*(-x134*x140 + x142*x144 + 0.10095114404623
     &d0*x4))))
      d1Ea(3) = -x0*x102*x136*x44*(0.0757133580346725d0*x121*x138*x145*x
     &3*x72*x78 + 0.0028125d0*x123*x137*x145*x99 - 0.00344377233585999d0
     &*x145*x62* x68 - x66*x96*(0.0818825946152754d0*x111 - x143*x146) +
     & 0.0720987654320988d0*x96*x97*(0.90856029641607d0*x111 - x144*x146
     & ))
      end subroutine


C*****************************************************************************
      pure subroutine D1ESRX_TPSS_GWS_ERF_case_2_2(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = 7.26848237132856d0*x1
      x3 = rho_a**(-2.66666666666667d0)
      x4 = 4.60115111447049d0
      x5 = 1d0/x4
      x6 = x3*x5
      x7 = gamma_aa*x6
      x8 = mu**2
      x9 = 1d0/x8
      x10 = 0.239205142311446d0*x9
      x11 = rho_a**0.666666666666667d0
      x12 = x11*x4
      x13 = 0.183440402716368d0*x12
      x14 = 21.1705915781930d0
      x15 = x14*x9
      x16 = 0.010095114404623d0*x0*x15
      x17 = rho_a**2.0d0
      x18 = 97.4090910340024d0
      x19 = x18/mu**4
      x20 = 0.147857142857143d0*x17*x19
      x21 = exp(-1.4385538026587772d0*x5*x8/x11)
      x22 = x21*(-x13 + x16 + x20)
      x23 = x10*x22*x7
      x24 = -x23 + 1.0d0
      x25 = 1.804d0 - 0.804d0/x24
      x26 = 2.14502939711103d0
      x27 = 1d0/x26
      x28 = rho_a**0.333333333333333d0
      x29 = 1d0/x28
      x30 = x27*x29
      x31 = 0.550321208149104d0*x30
      x32 = rho_a**1.0d0
      x33 = 1d0/x32
      x34 = 0.00844343197019481d0
      x35 = x33*x34
      x36 = x35*x8
      x37 = exp(-3.3019272488946267d0*x12*x9)
      x38 = mu*x37
      x39 = 1d0/mu
      x40 = x26*x39
      x41 = mu**3
      x42 = mu*x30
      x43 = x35*x41 - 0.825481812223657d0*x42 + 1.77245385090552d0*erf( 
     &1.8171205928321397d0*x28*x40)
      x44 = 0.275160604074552d0*x42
      x45 = x44*(x38*(x31 - x36) + x43) - 0.375d0
      x46 = x25*x45
      x47 = exp(-4.1274090611182839d0*x42)
      x48 = 0.0206714418186455d0*x7 + 1.0d0
      x49 = 0.804d0/x48
      x50 = 0.0938662444277524d0*x7 + 1.0d0
      x51 = x50**(-2)
      x52 = 0.050475572023115d0*x7
      x53 = tau_a/gamma_aa
      x54 = 8.0d0*rho_a*x53
      x55 = x54 - 1.0d0
      x56 = x55*x7
      x57 = 0.0567850185260044d0*x56 - 0.45d0
      x58 = 0.126188930057787d0*x55
      x59 = x58*x7 - 1.0d0
      x60 = x55*x59
      x61 = x52*x60 + 1.0d0
      x62 = x61**(-0.5d0)
      x63 = x52 + x57*x62
      x64 = x63**2
      x65 = 0.00909806606836394d0*x6
      x66 = gamma_aa*x65
      x67 = x62*(0.0102353243269094d0*x56 - 0.0811111111111111d0) + x66
      x68 = 1d0/x14
      x69 = rho_a**(-5.33333333333333d0)*x68
      x70 = rho_a**(-2)
      x71 = tau_a**(-2)
      x72 = 0.0028125d0*x71
      x73 = sqrt(0.00286625629244325d0*x69 + x70*x72)
      x74 = gamma_aa*x73
      x75 = x67*x74
      x76 = gamma_aa**2
      x77 = x69*x76
      x78 = rho_a**(-8.0d0)
      x79 = 1d0/x18
      x80 = gamma_aa**3
      x81 = x79*x80
      x82 = x78*x81
      x83 = x71*x76
      x84 = x70*x83
      x85 = 0.015625d0*x84 + 1.0d0
      x86 = x85**(-2)
      x87 = 0.02485875d0*x84*x86 + 0.123456790123457d0
      x88 = 0.0941708433267071d0*x87
      x89 = x7*x88 + 0.000135164574498753d0*x77 + 0.000182133424673508d0
     &*x82 + 0.0021416494625995d0*x84
      x90 = x51*(0.0896750813832074d0*x64 - 1.24378109452736d0*x75 + x89
     &) + 1.0d0
      x91 = -0.804d0/x90
      x92 = x47*(x49 + x91)
      x93 = 0.682784063255296d0
      x94 = 2.72568088924821d0*x93
      x95 = -x31 + x36
      x96 = -x38*x95 + x43
      x97 = -x54 + 1.0d0
      x98 = 0.0567850185260044d0*x97
      x99 = x7*x98 + 0.45d0
      x100 = x7*x97
      x101 = 0.126188930057787d0*x100 + 1.0d0
      x102 = x101*x52*x97 + 1.0d0
      x103 = x102**(-0.5d0)
      x104 = -x103*x99 + x52
      x105 = x104**2
      x106 = -x103*(0.0102353243269094d0*x100 + 0.0811111111111111d0) + 
     &x66
      x107 = 1.24378109452736d0*x106
      x108 = x51*(0.0896750813832074d0*x105 - x107*x74 + x89) + 1.0d0
      x109 = x47*x94
      x110 = rho_a**(-0.666666666666667d0)
      x111 = 1d0/x0
      x112 = x111*x27
      x113 = x34/x17
      x114 = rho_a**(-0.333333333333333d0)*x4
      x115 = 0.318309886183791d0*mu
      x116 = x13 - x16 - x20
      x117 = rho_a**(-4.33333333333333d0)*x68
      x118 = rho_a**(-3.66666666666667d0)
      x119 = x45/x24**2
      x120 = 0.148394183600699d0
      x121 = x120/x48**2
      x122 = 0.90856029641607d0*x110*x93
      x123 = rho_a**(-6.33333333333333d0)*x68
      x124 = rho_a**(-3)
      x125 = gamma_aa*x118
      x126 = x125*x5
      x127 = 0.001553671875d0*x84/x85 - 0.0497175d0
      x128 = 0.0941708433267071d0*x127*x5*x86
      x129 = 1d0/x73
      x130 = 1d0/x50
      x131 = 0.0757133580346725d0*x7*x87 + 0.000108672317896998d0*x77 + 
     &0.0001464352734375d0*x82 + 0.00172188616792999d0*x84
      x132 = tau_a*x3
      x133 = x125*x55
      x134 = x62*(0.454280148208035d0*x132 - 0.151426716069345d0*x133)
      x135 = 0.180246913580247d0*x5
      x136 = x5*x59
      x137 = 0.0252377860115575d0*gamma_aa*x3*x55*x68
      x138 = x57*x61**(-1.5d0)*(-0.20190228809246d0*x132*x136 + 0.067300
     &7626974867d0* x133*x136 - x137*(1.0095114404623d0*x132 - 0.3365038
     &13487433d0* x133))
      x139 = 1.24378109452736d0*x74
      x140 = 2.0d0*x5
      x141 = x28*x51*x93
      x142 = rho_a**(-2.33333333333333d0)
      x143 = x108**(-2)
      x144 = gamma_aa*x70
      x145 = rho_a**(-4.66666666666667d0)
      x146 = rho_a**(-1.66666666666667d0)
      x147 = x146*x53
      x148 = x103*(0.454280148208035d0*x147 + x3*x98)
      x149 = x146*x5
      x150 = 0.20190228809246d0*x149
      x151 = x102**(-1.5d0)*(x137*(-1.0095114404623d0*x147 + x3*x58) - x
     &150*x53*x59 + 0.0252377860115575d0*x6*x60)
      x152 = 0.180246913580247d0*x99
      x153 = 2.0d0*x99
      x154 = tau_a**(-3)
      x155 = (0.0254778337106067d0*gamma_aa*x117*x97 + x101*x150)/x102
      Ea = -x0*(-x2*x46 + x92*x94)
      d1Ea(1) = -rho_a*(-5.84385982654816d0*gamma_aa*x1*x119*x21*x28*(x1
     &0*x6*( -0.0134601525394973d0*rho_a**0.333333333333333d0*x15 + 0.12
     &2293601810912d0*x114 - 0.295714285714286d0*x19*x32) + 0.2294063113
     &91776d0*x116*x117 - 0.637880379497189d0*x116*x118*x5* x9) - 2.4228
     &2745710952d0*x1*x110*x46 + 7.26848237132856d0*x115* x25*x28*(0.091
     &7202013581841d0*x111*x96 - 0.275160604074552d0*x29* (0.27516060407
     &4552d0*mu*x112 + 1.21141372855476d0*x110*x37*x40 - x113*x41 + 2.20
     &128483259642d0*x114*x37*x39*x95 + x38*( -0.183440402716368d0*x112 
     &+ x113*x8))) + 3.75d0*x115*x33*x92 + x47*(0.12080100840081d0*gamma
     &_aa*rho_a**(-3.33333333333333d0)* x121 - x122*(-x49 + 1.804d0) + x
     &122*(x91 + 1.804d0) + 2.19144743495556d0*x141*(1.24378109452736d0*
     &gamma_aa*x129*x67*( 0.00764335011318201d0*x123 + x124*x72) - 0.001
     &45706739738806d0* rho_a**(-9.0d0)*x81 + rho_a**(-5.66666666666667d
     &0)*x128*x71*x80 - 0.000720877730660018d0*x123*x76 - 0.004283298925
     &19899d0*x124*x83 + 0.622661654578789d0*x126*x130*(x131 + 0.0720987
     &654320988d0*x64 - x75) - 0.251122248871219d0*x126*x87 - x139*( -0.
     &0242615095156372d0*x126 + x134*x135 + 0.180246913580247d0*x138 ) +
     & 0.0896750813832074d0*x63*(-0.269203050789947d0*x126 + x134* x140 
     &+ 2.0d0*x138))/x90**2)) - x109*x28*(x49 - 0.804d0/x108) + x2 *x28*
     &(1.804d0 + 0.804d0/(x23 - 1.0d0))*(x44*x96 - 0.375d0)
      d1Ea(2) = -rho_a*(1.39788132145759d0*x119*x120*x142*x22*x9 - 2.0d0
     &*x47*( 0.0226501890751519d0*x121*x142 + 1.09572371747778d0*x141*x1
     &43*( -0.000270329148997507d0*gamma_aa*x69 - 0.0896750813832074d0*x
     &104* (-x140*x148 + x151*x153 + 0.10095114404623d0*x6) + x107*x73 +
     & x128*x145*x83 + 0.233498120467046d0*x130*x6*(0.0720987654320988d0
     & *x105 - x106*x74 + x131) + x139*(-x135*x148 + x151*x152 + x65) - 
     &0.00428329892519899d0*x144*x71 - x6*x88 - 0.000546400274020523d0* 
     &x76*x78*x79)))
      d1Ea(3) = -x0*x109*x143*x51*(0.0720987654320988d0*x103*x104*(0.908
     &56029641607d0* x149 - x153*x155) - x103*x74*(0.0818825946152754d0*
     &x149 - x152* x155) + 0.0028125d0*x106*x129*x144*x154 + 0.075713358
     &0346725d0* x127*x145*x154*x5*x80*x86 - 0.00344377233585999d0*x154*
     &x70*x76)
      end subroutine


C*****************************************************************************
      pure subroutine D1ESRX_TPSS_GWS_ERF_case_2_3(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = 7.26848237132856d0*x1
      x3 = 1d0/x0
      x4 = 0.0472353356922751d0
      x5 = rho_a**0.666666666666667d0
      x6 = 4.60115111447049d0
      x7 = mu**2
      x8 = 1d0/x7
      x9 = x6*x8
      x10 = 3.30192724889463d0*x5*x9
      x11 = exp(x10)
      x12 = mu**4*x4*(x11 - 1.0d0)
      x13 = x12*x3
      x14 = 0.015286700226364d0*x13
      x15 = 7.0d0*x11 + 11.0d0
      x16 = 1d0/x6
      x17 = x16*x7/x5
      x18 = 0.00280419844572861d0*x15*x17
      x19 = -x14 + x18 + 0.0185185185185185d0
      x20 = 3.0d0*x11
      x21 = x20 - 2.0d0
      x22 = 2.14502939711103d0
      x23 = 1d0/x22
      x24 = rho_a**0.333333333333333d0
      x25 = 1d0/x24
      x26 = x23*x25
      x27 = mu*x26
      x28 = 1d0/mu
      x29 = x22*x28
      x30 = erf(1.8171205928321397d0*x24*x29)
      x31 = x11*x30
      x32 = 1d0/(0.183440402716368d0*x13 - 0.60570686427738d0*x17*x21 - 
     &x20 + 3.90167577847542d0*x27*x31)
      x33 = rho_a**(-2.0d0)
      x34 = 3.15935190989552d0*x33*x8
      x35 = x32*x34
      x36 = exp(-1.4385538026587772d0*x17)
      x37 = gamma_aa*x36
      x38 = x19*x35*x37
      x39 = -x38 + 1.0d0
      x40 = 1.804d0 - 0.804d0/x39
      x41 = 0.550321208149104d0*x26
      x42 = 1d0/rho_a
      x43 = 0.00844343197019481d0
      x44 = x42*x43
      x45 = x44*x7
      x46 = exp(-x10)
      x47 = mu*x46
      x48 = mu**3
      x49 = -0.825481812223657d0*x27 + 1.77245385090552d0*x30 + x44*x48
      x50 = 0.275160604074552d0*x27
      x51 = x50*(x47*(x41 - x45) + x49) - 0.375d0
      x52 = x40*x51
      x53 = exp(-4.1274090611182839d0*x27)
      x54 = rho_a**(-2.66666666666667d0)
      x55 = x16*x54
      x56 = gamma_aa*x55
      x57 = 0.0206714418186455d0*x56 + 1.0d0
      x58 = 0.804d0/x57
      x59 = 0.0938662444277524d0*x56 + 1.0d0
      x60 = x59**(-2)
      x61 = 0.050475572023115d0*x56
      x62 = tau_a/gamma_aa
      x63 = 8.0d0*rho_a*x62
      x64 = x63 - 1.0d0
      x65 = x56*x64
      x66 = 0.0567850185260044d0*x65 - 0.45d0
      x67 = 0.126188930057787d0*x65 - 1.0d0
      x68 = x61*x64*x67 + 1.0d0
      x69 = x68**(-0.5d0)
      x70 = x61 + x66*x69
      x71 = x70**2
      x72 = 0.00909806606836394d0*x55
      x73 = gamma_aa*x72
      x74 = x69*(0.0102353243269094d0*x65 - 0.0811111111111111d0) + x73
      x75 = rho_a**(-5.33333333333333d0)*x4
      x76 = rho_a**(-2)
      x77 = tau_a**(-2)
      x78 = 0.0028125d0*x77
      x79 = sqrt(0.00286625629244325d0*x75 + x76*x78)
      x80 = gamma_aa*x79
      x81 = x74*x80
      x82 = gamma_aa**2
      x83 = x75*x82
      x84 = rho_a**(-8.0d0)
      x85 = 0.0102659822546843d0
      x86 = gamma_aa**3
      x87 = x85*x86
      x88 = x84*x87
      x89 = x77*x82
      x90 = x76*x89
      x91 = 0.015625d0*x90 + 1.0d0
      x92 = x91**(-2)
      x93 = 0.02485875d0*x90*x92 + 0.123456790123457d0
      x94 = 0.0941708433267071d0*x93
      x95 = x56*x94 + 0.000135164574498753d0*x83 + 0.000182133424673508d
     &0*x88 + 0.0021416494625995d0*x90
      x96 = x60*(0.0896750813832074d0*x71 - 1.24378109452736d0*x81 + x95
     &) + 1.0d0
      x97 = -0.804d0/x96
      x98 = x53*(x58 + x97)
      x99 = 0.682784063255296d0
      x100 = 2.72568088924821d0*x99
      x101 = x38 - 1.0d0
      x102 = -x41 + x45
      x103 = -x102*x47 + x49
      x104 = x103*x50 - 0.375d0
      x105 = -x63 + 1.0d0
      x106 = x105*x56
      x107 = 0.0567850185260044d0*x106 + 0.45d0
      x108 = 0.126188930057787d0*x106 + 1.0d0
      x109 = x105*x108
      x110 = x109*x61 + 1.0d0
      x111 = x110**(-0.5d0)
      x112 = -x107*x111 + x61
      x113 = x112**2
      x114 = -x111*(0.0102353243269094d0*x106 + 0.0811111111111111d0) + 
     &x73
      x115 = 1.24378109452736d0*x114
      x116 = x60*(0.0896750813832074d0*x113 - x115*x80 + x95) + 1.0d0
      x117 = x100*x53
      x118 = rho_a**(-0.666666666666667d0)
      x119 = 0.318309886183791d0*mu
      x120 = x23*x3
      x121 = mu*x120
      x122 = x33*x43
      x123 = x118*x29
      x124 = rho_a**(-0.333333333333333d0)
      x125 = rho_a**(-3.66666666666667d0)
      x126 = x14 - x18 - 0.0185185185185185d0
      x127 = x11*x42
      x128 = rho_a**(-1.66666666666667d0)
      x129 = x128*x16
      x130 = x129*x7
      x131 = x11*x130
      x132 = rho_a**(-2.33333333333333d0)
      x133 = x12*x132
      x134 = x1*x32
      x135 = 0.148394183600699d0/x57**2
      x136 = 0.90856029641607d0*x118*x99
      x137 = rho_a**(-6.33333333333333d0)*x4
      x138 = rho_a**(-3)
      x139 = gamma_aa*x125
      x140 = x139*x16
      x141 = 0.001553671875d0*x90/x91 - 0.0497175d0
      x142 = 0.0941708433267071d0*x141*x16*x92
      x143 = 1d0/x79
      x144 = 1d0/x59
      x145 = 0.0757133580346725d0*x56*x93 + 0.000108672317896998d0*x83 +
     & 0.0001464352734375d0*x88 + 0.00172188616792999d0*x90
      x146 = tau_a*x54
      x147 = x139*x64
      x148 = x69*(0.454280148208035d0*x146 - 0.151426716069345d0*x147)
      x149 = 0.180246913580247d0*x16
      x150 = x16*x67
      x151 = gamma_aa*x4
      x152 = 0.0252377860115575d0*x151
      x153 = x66*x68**(-1.5d0)*(-0.20190228809246d0*x146*x150 + 0.067300
     &7626974867d0* x147*x150 - x152*x54*x64*(1.0095114404623d0*x146 - 0
     &.336503813487433d0*x147))
      x154 = 1.24378109452736d0*x80
      x155 = 2.0d0*x16
      x156 = x24*x60*x99
      x157 = x116**(-2)
      x158 = gamma_aa*x76
      x159 = rho_a**(-4.66666666666667d0)
      x160 = x128*x62
      x161 = x105*x54
      x162 = x111*(0.454280148208035d0*x160 + 0.0567850185260044d0*x161)
     &
      x163 = 0.20190228809246d0*x108*x129
      x164 = x110**(-1.5d0)*(0.0252377860115575d0*x109*x55 + x152*x161*(
     & 1.0095114404623d0*x160 + 0.126188930057787d0*x161) + x163*x62)
      x165 = 0.180246913580247d0*x107
      x166 = 2.0d0*x107
      x167 = tau_a**(-3)
      x168 = (0.0254778337106067d0*rho_a**(-4.33333333333333d0)*x105*x15
     &1 + x163)/ x110
      Ea = -x0*(x100*x98 - x2*x52)
      d1Ea(1) = -rho_a*(-2.42282745710952d0*x1*x118*x52 + 7.268482371328
     &56d0*x119*x24* x40*(0.0917202013581841d0*x103*x3 - 0.2751606040745
     &52d0*x25*( 2.20128483259642d0*x102*x124*x28*x46*x6 + 0.27516060407
     &4552d0* x121 - x122*x48 + 1.21141372855476d0*x123*x46 + x47*( -0.1
     &83440402716368d0*x120 + x122*x7))) + 3.75d0*x119*x42*x98 - 5.84385
     &982654816d0*x134*x24*x37*x51*(-6.31870381979104d0*rho_a**( -3.0d0)
     &*x126*x8 + 3.02993180261165d0*x125*x126*x16 + x126*x35*( 6.6038544
     &9778925d0*x11*x124*x9 + 1.30055859282514d0*x121*x31 - 8.5886997128
     &6677d0*x123*x31 + 4.0d0*x127 - 0.40380457618492d0* x130*x21 - 0.40
     &380457618492d0*x131 + 0.244587203621824d0*x133 - 2.66666666666667d
     &0*x42) + x34*(-0.0432098765432099d0*x127 + 0.00186946563048574d0*x
     &130*x15 + 0.0336503813487433d0*x131 - 0.0203822669684853d0*x133))/
     &x39**2 + x53*(0.12080100840081d0* gamma_aa*rho_a**(-3.333333333333
     &33d0)*x135 - x136*(-x58 + 1.804d0 ) + x136*(x97 + 1.804d0) + 2.191
     &44743495556d0*x156*( 1.24378109452736d0*gamma_aa*x143*x74*(0.00764
     &335011318201d0*x137 + x138*x78) - 0.00145706739738806d0*rho_a**(-9
     &.0d0)*x87 + rho_a** (-5.66666666666667d0)*x142*x77*x86 - 0.0007208
     &77730660018d0*x137* x82 - 0.00428329892519899d0*x138*x89 + 0.62266
     &1654578789d0*x140* x144*(x145 + 0.0720987654320988d0*x71 - x81) - 
     &0.251122248871219d0*x140*x93 - x154*(-0.0242615095156372d0*x140 + 
     &x148*x149 + 0.180246913580247d0*x153) + 0.0896750813832074d0*x70* 
     &(-0.269203050789947d0*x140 + x148*x155 + 2.0d0*x153))/x96**2)) + x
     &104*x2*x24*(1.804d0 + 0.804d0/x101) - x117*x24*(x58 - 0.804d0/ x11
     &6)
      d1Ea(2) = rho_a*(-18.4628097041666d0*rho_a**(-1.66666666666667d0)*
     &x104*x134*x19* x36*x8/x101**2 + 2.0d0*x53*(0.0226501890751519d0*x1
     &32*x135 + 1.09572371747778d0*x156*x157*(-0.000270329148997507d0*ga
     &mma_aa* x75 - 0.0896750813832074d0*x112*(-x155*x162 + x164*x166 + 
     &0.10095114404623d0*x55) + x115*x79 + x142*x159*x89 + 0.23349812046
     &7046d0*x144*x55*(0.0720987654320988d0*x113 - x114* x80 + x145) + x
     &154*(-x149*x162 + x164*x165 + x72) - 0.00428329892519899d0*x158*x7
     &7 - x55*x94 - 0.000546400274020523d0 *x82*x84*x85)))
      d1Ea(3) = -x0*x117*x157*x60*(0.0720987654320988d0*x111*x112*(0.908
     &56029641607d0* x129 - x166*x168) - x111*x80*(0.0818825946152754d0*
     &x129 - x165* x168) + 0.0028125d0*x114*x143*x158*x167 + 0.075713358
     &0346725d0* x141*x159*x16*x167*x86*x92 - 0.00344377233585999d0*x167
     &*x76*x82)
      end subroutine


C*****************************************************************************
      pure subroutine D1ESRX_TPSS_GWS_ERF_case_3(rho_a, gamma_aa, tau_a,
     & mu, Ea, d1Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      x0 = rho_a**1.0d0
      x1 = rho_a**(-2.66666666666667d0)
      x2 = 4.60115111447049d0
      x3 = 1d0/x2
      x4 = x1*x3
      x5 = gamma_aa*x4
      x6 = mu**2
      x7 = 1d0/x6
      x8 = 0.239205142311446d0*x7
      x9 = rho_a**0.666666666666667d0
      x10 = 0.183440402716368d0*x2*x9
      x11 = rho_a**1.33333333333333d0
      x12 = 21.1705915781930d0
      x13 = x12*x7
      x14 = 0.010095114404623d0*x11*x13
      x15 = 97.4090910340024d0
      x16 = mu**(-4)
      x17 = x15*x16
      x18 = 0.147857142857143d0*rho_a**2.0d0*x17
      x19 = exp(-1.4385538026587772d0*x3*x6/x9)
      x20 = x19*(-x10 + x14 + x18)
      x21 = x20*x5*x8
      x22 = -x21 + 1.0d0
      x23 = 3.14159265358979d0
      x24 = x23*x7
      x25 = 1.0d0*x24*(1.804d0 - 0.804d0/x22)
      x26 = 0.682784063255296d0
      x27 = rho_a**0.333333333333333d0
      x28 = x26*x27
      x29 = exp(-1.9241736577956332d0*mu/x27)
      x30 = 0.0206714418186455d0*x5 + 1.0d0
      x31 = 0.804d0/x30
      x32 = 0.0938662444277524d0*x5 + 1.0d0
      x33 = x32**(-2)
      x34 = 0.050475572023115d0*x5
      x35 = tau_a/gamma_aa
      x36 = 8.0d0*rho_a*x35
      x37 = x36 - 1.0d0
      x38 = x37*x5
      x39 = 0.0567850185260044d0*x38 - 0.45d0
      x40 = 0.126188930057787d0*x38 - 1.0d0
      x41 = x34*x37*x40 + 1.0d0
      x42 = x41**(-0.5d0)
      x43 = x34 + x39*x42
      x44 = x43**2
      x45 = 0.00909806606836394d0*x4
      x46 = gamma_aa*x45
      x47 = x42*(0.0102353243269094d0*x38 - 0.0811111111111111d0) + x46
      x48 = 1d0/x12
      x49 = rho_a**(-5.33333333333333d0)*x48
      x50 = rho_a**(-2)
      x51 = tau_a**(-2)
      x52 = 0.0028125d0*x51
      x53 = sqrt(0.00286625629244325d0*x49 + x50*x52)
      x54 = gamma_aa*x53
      x55 = x47*x54
      x56 = gamma_aa**2
      x57 = x49*x56
      x58 = rho_a**(-8.0d0)
      x59 = 1d0/x15
      x60 = gamma_aa**3
      x61 = x59*x60
      x62 = x58*x61
      x63 = x51*x56
      x64 = x50*x63
      x65 = 0.015625d0*x64 + 1.0d0
      x66 = x65**(-2)
      x67 = 0.02485875d0*x64*x66 + 0.123456790123457d0
      x68 = 0.0941708433267071d0*x67
      x69 = x5*x68 + 0.000135164574498753d0*x57 + 0.000182133424673508d0
     &*x62 + 0.0021416494625995d0*x64
      x70 = x33*(0.0896750813832074d0*x44 - 1.24378109452736d0*x55 + x69
     &) + 1.0d0
      x71 = -0.804d0/x70
      x72 = x29*(x31 + x71)
      x73 = x0*x25 + 2.72568088924821d0*x28*x72
      x74 = x10 - x14 - x18
      x75 = rho_a**(-4.33333333333333d0)*x48
      x76 = rho_a**(-3.66666666666667d0)
      x77 = 0.148394183600699d0/x30**2
      x78 = 0.90856029641607d0*rho_a**(-0.666666666666667d0)*x26
      x79 = rho_a**(-6.33333333333333d0)*x48
      x80 = rho_a**(-3)
      x81 = gamma_aa*x76
      x82 = x3*x81
      x83 = 0.001553671875d0*x64/x65 - 0.0497175d0
      x84 = 0.0941708433267071d0*x3*x66*x83
      x85 = 1d0/x53
      x86 = 1d0/x32
      x87 = 0.0757133580346725d0*x5*x67 + 0.000108672317896998d0*x57 + 0
     &.0001464352734375d0*x62 + 0.00172188616792999d0*x64
      x88 = tau_a*x1
      x89 = x37*x81
      x90 = x42*(0.454280148208035d0*x88 - 0.151426716069345d0*x89)
      x91 = 0.180246913580247d0*x3
      x92 = x3*x40
      x93 = 0.0252377860115575d0*gamma_aa*x48
      x94 = x39*x41**(-1.5d0)*(-x1*x37*x93*(1.0095114404623d0*x88 - 0.33
     &6503813487433d0*x89) - 0.20190228809246d0*x88*x92 + 0.067300762697
     &4867d0*x89*x92)
      x95 = 1.24378109452736d0*x54
      x96 = 2.0d0*x3
      x97 = x28*x33
      x98 = rho_a**(-1.66666666666667d0)
      x99 = -x36 + 1.0d0
      x100 = x5*x99
      x101 = 0.0567850185260044d0*x100 + 0.45d0
      x102 = 0.126188930057787d0*x100 + 1.0d0
      x103 = x102*x99
      x104 = x103*x34 + 1.0d0
      x105 = x104**(-0.5d0)
      x106 = -x101*x105 + x34
      x107 = x106**2
      x108 = -x105*(0.0102353243269094d0*x100 + 0.0811111111111111d0) + 
     &x46
      x109 = 1.24378109452736d0*x108
      x110 = (x33*(0.0896750813832074d0*x107 - x109*x54 + x69) + 1.0d0)*
     &*(-2)
      x111 = gamma_aa*x50
      x112 = rho_a**(-4.66666666666667d0)
      x113 = x35*x98
      x114 = x1*x99
      x115 = x105*(0.454280148208035d0*x113 + 0.0567850185260044d0*x114)
     &
      x116 = x3*x98
      x117 = 0.20190228809246d0*x102*x116
      x118 = x104**(-1.5d0)*(0.0252377860115575d0*x103*x4 + x114*x93*( 1
     &.0095114404623d0*x113 + 0.126188930057787d0*x114) + x117*x35)
      x119 = 0.180246913580247d0*x101
      x120 = 2.0d0*x101
      x121 = tau_a**(-3)
      x122 = (0.0254778337106067d0*gamma_aa*x75*x99 + x117)/x104
      Ea = -rho_a*x73
      d1Ea(1) = -rho_a*(0.804d0*gamma_aa*x0*x19*x24*(-0.637880379497189d
     &0*x3*x7*x74*x76 + x4*x8*(0.122293601810912d0*rho_a**(-0.3333333333
     &33333d0)*x2 - 0.0134601525394973d0*rho_a**0.333333333333333d0*x13 
     &- 0.295714285714286d0*x0*x17) + 0.229406311391776d0*x74*x75)/x22**
     &2 + 3.75d0*mu*x72/(x0*x23) + x25 + x29*(0.12080100840081d0*gamma_a
     &a *rho_a**(-3.33333333333333d0)*x77 - x78*(-x31 + 1.804d0) + x78*(
     & x71 + 1.804d0) + 2.19144743495556d0*x97*(1.24378109452736d0* gamm
     &a_aa*x47*x85*(x52*x80 + 0.00764335011318201d0*x79) - 0.00145706739
     &738806d0*rho_a**(-9.0d0)*x61 + rho_a**( -5.66666666666667d0)*x51*x
     &60*x84 + 0.0896750813832074d0*x43*( -0.269203050789947d0*x82 + x90
     &*x96 + 2.0d0*x94) - 0.000720877730660018d0*x56*x79 - 0.00428329892
     &519899d0*x63*x80 - 0.251122248871219d0*x67*x82 + 0.622661654578789
     &d0*x82*x86*( 0.0720987654320988d0*x44 - x55 + x87) - x95*( -0.0242
     &615095156372d0*x82 + x90*x91 + 0.180246913580247d0*x94))/ x70**2))
     & - x73
      d1Ea(2) = rho_a*(0.131313669051252d0*x16*x20*x98/(x21 - 1.0d0)**2 
     &+ 2.0d0*x29*( 0.0226501890751519d0*rho_a**(-2.33333333333333d0)*x7
     &7 + 1.09572371747778d0*x110*x97*(-0.000270329148997507d0*gamma_aa*
     &x49 - 0.0896750813832074d0*x106*(-x115*x96 + x118*x120 + 0.1009511
     &4404623d0*x4) + x109*x53 - 0.00428329892519899d0*x111* x51 + x112*
     &x63*x84 - x4*x68 + 0.233498120467046d0*x4*x86*( 0.0720987654320988
     &d0*x107 - x108*x54 + x87) - 0.000546400274020523d0*x56*x58*x59 + x
     &95*(-x115*x91 + x118*x119 + x45))))
      d1Ea(3) = -2.72568088924821d0*x11*x110*x26*x29*x33*(0.072098765432
     &0988d0*x105*x106 *(0.90856029641607d0*x116 - x120*x122) - x105*x54
     &*( 0.0818825946152754d0*x116 - x119*x122) + 0.0028125d0*x108*x111*
     & x121*x85 + 0.0757133580346725d0*x112*x121*x3*x60*x66*x83 - 0.0034
     &4377233585999d0*x121*x50*x56)
      end subroutine


C*****************************************************************************
      pure subroutine D2ESRX_TPSS_GWS_ERF_case_1(rho_a, gamma_aa, tau_a,
     & mu, Ea, d1Ea, d2Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4), d2Ea(10)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168, x169, x170
     &, x171, x172, x173, x174, x175, x176, x177, x178, x179, x180, x181
     &, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192
     &, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203
     &, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, x214
     &, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225
     &, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236
     &, x237, x238, x239, x240, x241, x242, x243, x244, x245, x246, x247
     &, x248, x249, x250, x251, x252, x253, x254, x255, x256, x257, x258
     &, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269
     &, x270, x271, x272, x273, x274, x275, x276, x277, x278, x279, x280
     &, x281, x282, x283, x284, x285, x286, x287, x288, x289, x290, x291
     &, x292, x293, x294, x295, x296, x297, x298, x299, x300, x301, x302
     &, x303, x304, x305, x306, x307, x308, x309, x310, x311, x312, x313
     &, x314, x315, x316, x317, x318, x319, x320, x321, x322, x323, x324
     &, x325, x326, x327, x328, x329, x330, x331, x332, x333, x334, x335
     &, x336, x337, x338, x339, x340, x341, x342, x343, x344, x345, x346
     &, x347, x348, x349, x350, x351, x352, x353, x354, x355, x356, x357
     &, x358, x359, x360, x361, x362, x363, x364, x365, x366, x367, x368
     &, x369, x370, x371, x372, x373, x374, x375, x376, x377, x378, x379
     &, x380, x381, x382, x383, x384, x385, x386, x387, x388, x389, x390
     &, x391, x392, x393, x394, x395
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      d2Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = rho_a**(-2.66666666666667d0)
      x3 = 0.217336917462899d0
      x4 = x2*x3
      x5 = gamma_aa*x4
      x6 = mu**2
      x7 = rho_a**(-0.666666666666667d0)*x3*x6
      x8 = 5.45136177849642d0*x7 - 7.0d0
      x9 = 0.239205142311446d0*x8
      x10 = 0.826307487110758d0
      x11 = rho_a**0.333333333333333d0
      x12 = mu/x11
      x13 = 0.0472353356922751d0
      x14 = mu**4
      x15 = 1d0/x0
      x16 = 59.4346904801033d0*x10*x12 + 4.95289087334194d0*x13*x14*x15 
     &- 49.0622560064678d0*x7 - 81.0d0
      x17 = 1d0/x16
      x18 = x17*exp(-1.4385538026587772d0*x7)
      x19 = x18*x5*x9 + 1.0d0
      x20 = x1*(1.804d0 - 0.804d0/x19)
      x21 = 2.72568088924821d0*x20
      x22 = 0.682784063255296d0
      x23 = 2.72568088924821d0*x22
      x24 = 0.466194077035412d0
      x25 = exp(-4.1274090611182839d0*x12*x24)
      x26 = 0.0206714418186455d0*x5 + 1.0d0
      x27 = 0.804d0/x26
      x28 = 0.0938662444277524d0*x5 + 1.0d0
      x29 = x28**(-2)
      x30 = 0.050475572023115d0*x5
      x31 = 1d0/gamma_aa
      x32 = tau_a*x31
      x33 = 8.0d0*rho_a*x32
      x34 = x33 - 1.0d0
      x35 = x34*x5
      x36 = 0.0567850185260044d0*x35 - 0.45d0
      x37 = 0.126188930057787d0*x35 - 1.0d0
      x38 = x34*x37
      x39 = x30*x38 + 1.0d0
      x40 = x39**(-0.5d0)
      x41 = x30 + x36*x40
      x42 = x41**2
      x43 = rho_a**(-5.33333333333333d0)*x13
      x44 = rho_a**(-2)
      x45 = tau_a**(-2)
      x46 = 0.0028125d0*x45
      x47 = 0.00286625629244325d0*x43 + x44*x46
      x48 = sqrt(x47)
      x49 = 0.00909806606836394d0*x4
      x50 = gamma_aa*x49
      x51 = x40*(0.0102353243269094d0*x35 - 0.0811111111111111d0) + x50
      x52 = x48*x51
      x53 = gamma_aa*x52
      x54 = gamma_aa**2
      x55 = x43*x54
      x56 = rho_a**(-8.0d0)
      x57 = 0.0102659822546843d0
      x58 = gamma_aa**3
      x59 = x57*x58
      x60 = x56*x59
      x61 = x44*x45
      x62 = x54*x61
      x63 = 0.015625d0*x62 + 1.0d0
      x64 = x63**(-2)
      x65 = 0.02485875d0*x62*x64 + 0.123456790123457d0
      x66 = x5*x65
      x67 = 0.000135164574498753d0*x55 + 0.000182133424673508d0*x60 + 0.
     &0021416494625995d0*x62 + 0.0941708433267071d0*x66
      x68 = x29*(0.0896750813832074d0*x42 - 1.24378109452736d0*x53 + x67
     &) + 1.0d0
      x69 = 1d0/x68
      x70 = -0.804d0*x69
      x71 = x25*(x27 + x70)
      x72 = x23*x71
      x73 = rho_a**(-0.666666666666667d0)
      x74 = x20*x73
      x75 = rho_a**(-4.33333333333333d0)
      x76 = x13*x75
      x77 = x6*x76
      x78 = rho_a**(-3.66666666666667d0)
      x79 = x3*x78
      x80 = x79*x8
      x81 = x77*x8
      x82 = x10*x15
      x83 = rho_a**(-1.66666666666667d0)
      x84 = x3*x83
      x85 = mu*x84
      x86 = rho_a**(-2.33333333333333d0)
      x87 = mu**3
      x88 = x13*x87
      x89 = x86*x88
      x90 = 19.8115634933678d0*x82 - 32.7081706709785d0*x85 + 6.60385449
     &778925d0*x89
      x91 = x17*x90
      x92 = mu*x4
      x93 = x9*x92
      x94 = -0.869329180010942d0*x77 - 0.637880379497189d0*x80 + 0.22940
     &6311391776d0 *x81 + x91*x93
      x95 = x18/x19**2
      x96 = x1*x94*x95
      x97 = 2.19144743495556d0*x11
      x98 = x96*x97
      x99 = 0.318309886183791d0*mu
      x100 = 1d0/rho_a*x99
      x101 = 3.75d0*x100
      x102 = rho_a**(-3.33333333333333d0)
      x103 = 0.148394183600699d0
      x104 = x103/x26**2
      x105 = x102*x104
      x106 = -x27 + 1.804d0
      x107 = 0.90856029641607d0*x73
      x108 = x107*x22
      x109 = x68**(-2)
      x110 = 2.19144743495556d0*x11
      x111 = rho_a**(-9.0d0)
      x112 = x111*x59
      x113 = rho_a**(-6.33333333333333d0)*x13
      x114 = x113*x54
      x115 = rho_a**(-3)
      x116 = x115*x45
      x117 = x116*x54
      x118 = gamma_aa*x79
      x119 = 0.251122248871219d0*x65
      x120 = x62/x63
      x121 = 0.001553671875d0*x120
      x122 = x121 - 0.0497175d0
      x123 = x122*x58
      x124 = x45*x64
      x125 = 0.0941708433267071d0*x124
      x126 = rho_a**(-5.66666666666667d0)*x3
      x127 = x125*x126
      x128 = 0.00764335011318201d0*x113 + x115*x46
      x129 = 1d0/x48
      x130 = x129*x51
      x131 = x128*x130
      x132 = gamma_aa*x131
      x133 = 1d0/x28
      x134 = 0.000108672317896998d0*x55 + 0.0001464352734375d0*x60 + 0.0
     &0172188616792999d0*x62 + 0.0757133580346725d0*x66
      x135 = x134 + 0.0720987654320988d0*x42 - x53
      x136 = x133*x135
      x137 = 0.622661654578789d0*x136
      x138 = 0.0242615095156372d0*x79
      x139 = tau_a*x2
      x140 = x34*x78
      x141 = 0.151426716069345d0*x140
      x142 = -gamma_aa*x141 + 0.454280148208035d0*x139
      x143 = x142*x40
      x144 = 0.180246913580247d0*x3
      x145 = x3*x37
      x146 = 0.20190228809246d0*x139
      x147 = 0.0673007626974867d0*x38
      x148 = 0.336503813487433d0*x140
      x149 = x13*(-gamma_aa*x148 + 1.0095114404623d0*x139)
      x150 = x2*x34
      x151 = 0.0252377860115575d0*x150
      x152 = x149*x151
      x153 = -gamma_aa*x152 + x118*x147 - x145*x146
      x154 = x39**(-1.5d0)
      x155 = x154*x36
      x156 = x153*x155
      x157 = -gamma_aa*x138 + x143*x144 + 0.180246913580247d0*x156
      x158 = x157*x48
      x159 = gamma_aa*x158
      x160 = 0.269203050789947d0*x79
      x161 = 2.0d0*x3
      x162 = -gamma_aa*x160 + x143*x161 + 2.0d0*x156
      x163 = x162*x41
      x164 = -0.00145706739738806d0*x112 - 0.000720877730660018d0*x114 -
     & 0.00428329892519899d0*x117 - x118*x119 + x118*x137 + x123*x127 + 
     &1.24378109452736d0*x132 - 1.24378109452736d0*x159 + 0.089675081383
     &2074d0*x163
      x165 = x22*x29
      x166 = x164*x165
      x167 = x25*(0.12080100840081d0*gamma_aa*x105 - x106*x108 + x108*(x
     &70 + 1.804d0 ) + x109*x110*x166)
      x168 = x103*x86
      x169 = x168*x8
      x170 = 0.524205495546598d0*x169*x95
      x171 = x104*x86
      x172 = 0.0226501890751519d0*x171
      x173 = -x33 + 1.0d0
      x174 = x173*x5
      x175 = 0.0567850185260044d0*x174 + 0.45d0
      x176 = 0.126188930057787d0*x174 + 1.0d0
      x177 = x173*x176
      x178 = x177*x30 + 1.0d0
      x179 = x178**(-0.5d0)
      x180 = -x175*x179 + x30
      x181 = 2.0d0*x175
      x182 = x178**(-1.5d0)
      x183 = 0.20190228809246d0*x84
      x184 = x183*x37
      x185 = x184*x32
      x186 = x37*x4
      x187 = x186*x34
      x188 = 0.0252377860115575d0*x187
      x189 = x32*x83
      x190 = 1.0095114404623d0*x189
      x191 = 0.126188930057787d0*x2
      x192 = -x190 + x191*x34
      x193 = gamma_aa*x13
      x194 = x151*x193
      x195 = x192*x194
      x196 = -x185 + x188 + x195
      x197 = x182*x196
      x198 = 0.10095114404623d0*x4
      x199 = 0.454280148208035d0*x189
      x200 = 0.0567850185260044d0*x2
      x201 = x173*x200 + x199
      x202 = x179*x201
      x203 = -x161*x202 + x198
      x204 = x181*x197 + x203
      x205 = x180*x204
      x206 = 0.180246913580247d0*x175
      x207 = -x144*x202 + x49
      x208 = x197*x206 + x207
      x209 = gamma_aa*x48
      x210 = 1.24378109452736d0*x209
      x211 = x179*(0.0102353243269094d0*x174 + 0.0811111111111111d0)
      x212 = -x211 + x50
      x213 = x212*x48
      x214 = 1.24378109452736d0*x213
      x215 = 0.000270329148997507d0*x43
      x216 = x4*x65
      x217 = 0.00428329892519899d0*x61
      x218 = x54*x57
      x219 = x218*x56
      x220 = x180**2
      x221 = -gamma_aa*x213 + x134 + 0.0720987654320988d0*x220
      x222 = x133*x4
      x223 = 0.233498120467046d0*x222
      x224 = rho_a**(-4.66666666666667d0)
      x225 = x224*x3
      x226 = x225*x54
      x227 = x122*x226
      x228 = -gamma_aa*x215 - gamma_aa*x217 + x125*x227 + x214 - 0.09417
     &08433267071d0 *x216 - 0.000546400274020523d0*x219 + x221*x223
      x229 = -0.0896750813832074d0*x205 + x208*x210 + x228
      x230 = x165*x229
      x231 = x29*(-gamma_aa*x214 + 0.0896750813832074d0*x220 + x67) + 1.
     &0d0
      x232 = x231**(-2)
      x233 = x11*x232
      x234 = 1.09572371747778d0*x233
      x235 = 2.0d0*x25
      x236 = 0.90856029641607d0*x84
      x237 = 1d0/x178
      x238 = 0.0254778337106067d0*x75
      x239 = x173*x193
      x240 = x176*x183
      x241 = x237*(x238*x239 + x240)
      x242 = 0.0720987654320988d0*x179*x180
      x243 = 0.0818825946152754d0*x84
      x244 = x179*x209
      x245 = tau_a**(-3)
      x246 = x245*x44
      x247 = gamma_aa*x246
      x248 = x129*x247
      x249 = x245*x54
      x250 = 0.0757133580346725d0*x123
      x251 = x245*x64
      x252 = x225*x250*x251 - 0.00344377233585999d0*x249*x44
      x253 = 0.0028125d0*x212*x248 + x252
      x254 = x242*(-x181*x241 + x236) - x244*(-x206*x241 + x243) + x253
      x255 = x25*x29
      x256 = x0*x232*x255
      x257 = gamma_aa*x96
      x258 = 0.60570686427738d0*rho_a**(-1.66666666666667d0)
      x259 = 1.27576075899438d0*x80
      x260 = x1*x97
      x261 = x16**(-2)
      x262 = x261*exp(-2.8771076053175544d0*x7)/x19**3
      x263 = x262*x94
      x264 = rho_a**(-6.0d0)
      x265 = x14*x264*x57
      x266 = x43*x6
      x267 = x76*x87*x91
      x268 = mu*x15*x24
      x269 = 0.0322515344331995d0
      x270 = x269/x26**3
      x271 = x22*x258
      x272 = 1d0/x231
      x273 = x232*x73
      x274 = x118*x65
      x275 = x124*x126
      x276 = 1.24532330915758d0*x118
      x277 = x22/(x231**3*x28**4)
      x278 = x110*x164*x277
      x279 = rho_a**(-7.33333333333333d0)*x13
      x280 = x279*x54
      x281 = rho_a**(-4)
      x282 = x281*x45
      x283 = gamma_aa*x224
      x284 = x283*x3
      x285 = rho_a**(-6.66666666666667d0)*x3
      x286 = tau_a**(-4)
      x287 = x286*x64
      x288 = 0.00014565673828125d0*gamma_aa**4*x281*x287
      x289 = x58*(-0.010875703125d0*x120 + x288 + 0.1491525d0)
      x290 = 1.24378109452736d0*x130
      x291 = 1.24378109452736d0*gamma_aa
      x292 = x47**(-1.5d0)
      x293 = x292*x51
      x294 = x135*x29
      x295 = x128*x129
      x296 = 0.0720987654320988d0*x3
      x297 = 1.24378109452736d0*x162
      x298 = tau_a*x78
      x299 = x283*x34
      x300 = x40*(-2.42282745710952d0*x298 + 0.555231292254265d0*x299)
      x301 = 0.360493827160494d0*x3
      x302 = x153*x154
      x303 = x142*x302
      x304 = gamma_aa*x149
      x305 = x155*(-0.40380457618492d0*x139*x149 + 0.134601525394973d0*x
     &140*x304 + 1.07681220315979d0*x145*x298 - 0.246769463224118d0*x145
     &*x299 - x194*(-5.38406101579893d0*x298 + 1.23384731612059d0*x299))
     &
      x306 = 0.60570686427738d0*x37
      x307 = 0.0757133580346725d0*x150
      x308 = x153*x36
      x309 = x308*x39**(-2.5d0)
      x310 = x309*(0.20190228809246d0*x118*x38 - x139*x3*x306 - x304*x30
     &7)
      x311 = 0.00363922642734557d0*x4
      x312 = gamma_aa*x311
      x313 = x312 + x40*(0.00409412973076377d0*x35 - 0.0324444444444444d
     &0)
      x314 = 1.24378109452736d0*x313
      x315 = -0.0011714821875d0*x112 - 0.000579585695450655d0*x114 - 0.0
     &0344377233585999d0*x117 + x132 - x159 + 0.0720987654320988d0* x163
     & + x250*x275 - 0.20190228809246d0*x274
      x316 = x165*x232
      x317 = x110*x316
      x318 = x182*(0.0252377860115575d0*x177*x4 + 0.0252377860115575d0*x
     &2*x239*(x173* x191 + x190) + x240*x32)
      x319 = -0.0896750813832074d0*x180*(x181*x318 + x203) + x210*(x206*
     &x318 + x207) + x228
      x320 = x165*x234
      x321 = gamma_aa*x43
      x322 = 0.00856659785039798d0*gamma_aa
      x323 = 0.466996240934092d0*x222
      x324 = 0.188341686653414d0*x124*x227 - 0.179350162766415d0*x205 + 
     &2.48756218905473d0*x208*x209 + 2.48756218905473d0*x213 - 0.1883416
     &86653414d0*x216 - 0.00109280054804105d0*x219 + x221*x323 - 0.00054
     &0658297995013d0*x321 - x322*x61
      x325 = gamma_aa*x113
      x326 = -x121 + 0.0497175d0
      x327 = x127*x54
      x328 = 0.00932203125d0*x120
      x329 = -x199 + x200*x34
      x330 = x329*x40
      x331 = x185 - x188 - x195
      x332 = x155*x331
      x333 = x144*x330 + 0.180246913580247d0*x332 + x49
      x334 = x291*x295
      x335 = x296*x330 + x311 + 0.0720987654320988d0*x332
      x336 = x124*x326
      x337 = x333*x48
      x338 = x161*x330 + x198 + 2.0d0*x332
      x339 = 0.0720987654320988d0*x41
      x340 = -gamma_aa*x337 + 0.00344377233585999d0*gamma_aa*x61 + 0.075
     &7133580346725d0*x216 + 0.0004393058203125d0*x219 + 0.0757133580346
     &725d0*x226*x336 + 0.000217344635793995d0*x321 + x338*x339 - x52
      x341 = 0.622661654578789d0*x118*x133
      x342 = x139*x31
      x343 = x40*(-x141 + 1.21141372855476d0*x342)
      x344 = x302*x329
      x345 = x154*x331
      x346 = x142*x144
      x347 = x306*x84
      x348 = x192*x193
      x349 = -0.0757133580346725d0*x187 - x307*x348 + x32*x347
      x350 = x309*x349
      x351 = 0.20190228809246d0*x83
      x352 = x149*x351
      x353 = x155*(-x13*x146*x192 + 0.0673007626974867d0*x140*x348 - 0.5
     &38406101579893d0*x145*x342 + x147*x79 - x152 - x194*(-x148 + 2.692
     &03050789947d0*x342) + x32*x352)
      x354 = x142*x161
      x355 = rho_a**(-5.0d0)
      x356 = x13*x36
      x357 = x192*x356*(-0.050475572023115d0*x150 + 0.40380457618492d0*x
     &189)
      x358 = x329*x331
      x359 = 1d0/x39
      x360 = x359*x36
      x361 = x331*x349*x360
      x362 = x238*x34
      x363 = x184 + x193*x362
      x364 = x237*x363
      x365 = x181*x364 + x236
      x366 = x206*x364 + x243
      x367 = x242*x365 - x244*x366 + x253
      x368 = x360*x363
      x369 = 2.0d0*x368
      x370 = 0.180246913580247d0*x368
      x371 = x40*(x243 - x370)
      x372 = 0.0028125d0*x130*x247 - x209*x371 + x252 + x339*x40*(x236 -
     & x369)
      x373 = x126*x251
      x374 = x288 - x328 + 0.099435d0
      x375 = 0.0327530378461102d0*x84
      x376 = x359*x363
      x377 = x360*(-0.203822669684853d0*tau_a*x76 + 0.336503813487433d0*
     &x186 + 0.110403946079296d0*x321*x34 - x352)
      x378 = x153*x359
      x379 = 0.0764335011318201d0*gamma_aa*x34*x76 + x347
      x380 = x308*x379/x39**2
      x381 = 0.103185226527957d0*x225*x249*x64
      x382 = 1.3628404446241d0*x129*x246
      x383 = 1.3628404446241d0*x179
      x384 = 0.0720987654320988d0*x175*x364 + x375
      x385 = x201*x363
      x386 = x13*(-0.203822669684853d0*x102*x32 + x192*x351 + x362)
      x387 = x196*x237*x379
      x388 = 1.3628404446241d0*x182
      x389 = -x179*(0.00409412973076377d0*x174 + 0.0324444444444444d0) +
     & x312
      x390 = x272*x29
      x391 = x286*x44
      x392 = gamma_aa*x212
      x393 = x102*x356
      x394 = x363*x84
      x395 = 2.72568088924821d0*x154
      Ea = -x0*(x21 + x72)
      d1Ea(1) = -rho_a*(gamma_aa*x98 + x101*x71 + x167 + 0.9085602964160
     &7d0*x74) - x11* x21 - x11*x72
      d1Ea(2) = -rho_a*(x170 - x235*(x172 + x230*x234))
      d1Ea(3) = -x23*x254*x256
      d2Ea(1) = rho_a*(-gamma_aa*x260*x95*(-mu*x259*x91 + x17*x93*(-26.4
     &15417991157d0* x10*x86 - 15.4089938281749d0*x102*x88 + 54.51361778
     &49642d0*x92) + 2.33889472482303d0*x225*x8 + x261*x4*x6*x9*x90*( 39
     &.6231269867355d0*x82 - 65.416341341957d0*x85 + 13.2077089955785d0*
     &x89) + 0.220008881071042d0*x265*x8 - 1.66743573022264d0*x265 - 1.6
     &0584417974243d0*x266*x8 + 6.08530426007659d0*x266 + 0.458812622783
     &553d0*x267*x8 - 1.73865836002188d0*x267) + 5.0d0*rho_a**(-2.0d0)*x
     &71*x99 - 2.75160604074552d0*x167*x268 - 5.15926132639785d0*x168*x6
     &*x71 + x20*x258 + x25*(0.36240302520243d0*gamma_aa*x104*x75 - 0.01
     &33180320895522d0*rho_a**(-7.0d0)*x270*x54 - x106*x271 - 1.46096495
     &663704d0*x166*x273 + x271*(-0.804d0*x272 + 1.804d0) + x278*(-0.002
     &91413479477612d0*x112 - 0.00144175546132004d0*x114 - 0.00856659785
     &039798d0*x117 + 0.188341686653414d0*x123*x275 + 2.48756218905473d0
     &*x132 + x136*x276 - 2.48756218905473d0*x159 + 0.179350162766415d0*
     &x163 - 0.502244497742438d0*x274) - x317*( 2.48756218905473d0*gamma
     &_aa*x157*x295 - gamma_aa*x290*( 0.0484078840501527d0*x279 + 0.0084
     &375d0*x282) + 0.0131136065764925d0*rho_a**(-10.0d0)*x59 - 0.502244
     &497742438d0* x123*x124*x285 + x125*x285*x289 + x128**2*x291*x293 +
     & x133*x276* x315 - 2.28309273345556d0*x136*x284 - x210*(x144*x300 
     &+ 0.0889588682240029d0*x284 + x301*x303 + 0.180246913580247d0*x305
     & + 0.180246913580247d0*x310) + 0.46757528851585d0*x280*x294 + 0.00
     &456555896084678d0*x280 + 0.012849896775597d0*x282*x54 + 0.92078157
     &9194469d0*x284*x65 + x297*(-0.00970460380625487d0*x118 + x143*x296
     & + 0.0720987654320988d0*x156) + x314*(x161*x300 + 0.98707785289647
     &1d0*x284 + 4.0d0*x3*x303 + 2.0d0*x305 + 2.0d0* x310))) - 1.4609649
     &5663704d0*x257*x73 + x260*x263*x54*(-x259 - 1.73865836002188d0*x77
     & + 0.478410284622892d0*x8*x91*x92 + 0.458812622783553d0*x81)) - 7.
     &5d0*x100*x71 - 4.38289486991112d0* x11*x257 - 2.0d0*x167 - 1.81712
     &059283214d0*x74
      d2Ea(2) = rho_a*(1.0484109910932d0*gamma_aa*x169*x263 - 0.17473516
     &5182199d0*x102* x103*x8*x95 + 1.37580302037276d0*x25*x268*(0.04530
     &03781503037d0* x171 + x317*x319) - x25*(-0.00499426203358209d0*gam
     &ma_aa*x264* x270 + 0.105700882350709d0*x105 - 0.73048247831852d0*x
     &230*x273 + x278*x324 + x317*(-0.00437120219216418d0*x111*x218 - x1
     &16*x322 - x119*x79 + x122*x327 - 1.24378109452736d0*x131 + x137*x7
     &9 - 1.24378109452736d0*x158 - x210*(-x138 + x144*x343 + x144*x344 
     &+ x345*x346 + 0.180246913580247d0*x350 + 0.180246913580247d0*x353)
     & - x223*x315 - 0.251122248871219d0*x275*x326*x54 + x290*( 0.015286
     &700226364d0*x113 + 0.005625d0*x116) - 0.175340733193444d0 *x294*x3
     &25 + x297*x335 + x314*(-x160 + x161*x343 + x161*x344 + x345*x354 +
     & 2.0d0*x350 + 2.0d0*x353) - 0.00144175546132004d0*x325 + x327*(-x2
     &88 + x328 - 0.099435d0) + x333*x334 + x340*x341)) - x98) - x170 + 
     &x235*(x172 + x319*x320)
      d2Ea(3) = rho_a*(-x235*(-1.09572371747778d0*x11*x229*x277*x324 + 0
     &.000936424131296642d0*x270*x355 + x320*(0.00109280054804105d0* gam
     &ma_aa*x56*x57 + x125*x284*(-0.007768359375d0*x120 + x288 + 0.04971
     &75d0) - x154*x210*(x301*x358 + 0.180246913580247d0*x357 + 0.180246
     &913580247d0*x361) + 2.48756218905473d0*x154*x313*(x161* x358 + x35
     &7 + x361) + x215 + x217 + 0.188341686653414d0*x284*x336 + 0.065752
     &7749475415d0*x294*x43 - x323*x340 + 1.24378109452736d0* x335*x338 
     &- 2.48756218905473d0*x337)) + 0.250785300325332d0*x262* x269*x355*
     &x8**2)
      d2Ea(4) = -x255*(rho_a*x109*(x101*x372 - x22*(-x107*x372 + 5.45136
     &177849642d0*x11* x164*x29*x372*x69 - x110*(-0.00699626865671642d0*
     &gamma_aa*x115* x130*x245 + 0.00856659785039798d0*x115*x249 - 0.251
     &122248871219d0 *x123*x373 + 0.00349813432835821d0*x128*x247*x293 +
     & 0.00349813432835821d0*x157*x248 - x210*x40*(x243*x378 - x346*x376
     & + 0.180246913580247d0*x377 - 0.180246913580247d0*x380 - 0.1364709
     &91025459d0*x4) + x297*x40*(-0.0720987654320988d0*x368 + x375) + x3
     &14*x40*(x236*x378 - x354*x376 + 2.0d0*x377 - 2.0d0*x380 - 1.514267
     &16069345d0*x4) + x334*x371 + x341*x372 + 0.0941708433267071d0*x373
     &*x374*x58))) + x23*x233*x367)
      d2Ea(5) = x0*x235*x316*(-x122*x381 - x204*x383*x384 - 0.0038329887
     &5050529d0*x208* x248 + x209*x388*(x144*x385 - x196*x243 + x206*x38
     &6 - x206*x387) + 0.255849428582226d0*x222*x254 + 0.009386624442775
     &24d0*x247 - 2.72568088924821d0*x254*x319*x390 + x366*x383*x48 + x3
     &74*x381 - x382*(-0.005625d0*x211 + 5.11766216345471d-5*x5) + x382*
     &( -0.0028125d0*x211 + 2.55883108172736d-5*x5) - x388*x389*(x161* x
     &385 + x181*x386 - x181*x387 - x196*x236))
      d2Ea(6) = x22*x256*(0.0229979325030318d0*x129*x391*x392 - 0.015331
     &9550020212d0* x179*x248*x366 - x209*x395*(-x370*x379 + 0.073476814
     &256762d0*x393 + 0.163765189230551d0*x394) - 0.206370453055914d0*x2
     &25*x287*x289 - 2.72568088924821d0*x237*x365*x384 + 6.7803007195229
     &1d0*x367**2* x390 + x389*x395*(-x369*x379 + 0.815290678739414d0*x3
     &93 + 1.81712059283214d0*x394) - 0.0281598733283257d0*x391*x54 - 2.
     &15605617215923d-5*x281*x292*x392/tau_a**6)
      end subroutine


C*****************************************************************************
      pure subroutine D2ESRX_TPSS_GWS_ERF_case_2_1(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea, d2Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4), d2Ea(10)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168, x169, x170
     &, x171, x172, x173, x174, x175, x176, x177, x178, x179, x180, x181
     &, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192
     &, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203
     &, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, x214
     &, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225
     &, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236
     &, x237, x238, x239, x240, x241, x242, x243, x244, x245, x246, x247
     &, x248, x249, x250, x251, x252, x253, x254, x255, x256, x257, x258
     &, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269
     &, x270, x271, x272, x273, x274, x275, x276, x277, x278, x279, x280
     &, x281, x282, x283, x284, x285, x286, x287, x288, x289, x290, x291
     &, x292, x293, x294, x295, x296, x297, x298, x299, x300, x301, x302
     &, x303, x304, x305, x306, x307, x308, x309, x310, x311, x312, x313
     &, x314, x315, x316, x317, x318, x319, x320, x321, x322, x323, x324
     &, x325, x326, x327, x328, x329, x330, x331, x332, x333, x334, x335
     &, x336, x337, x338, x339, x340, x341, x342, x343, x344, x345, x346
     &, x347, x348, x349, x350, x351, x352, x353, x354, x355, x356, x357
     &, x358, x359, x360, x361, x362, x363, x364, x365, x366, x367, x368
     &, x369, x370, x371, x372, x373, x374, x375, x376, x377, x378, x379
     &, x380, x381, x382, x383, x384, x385, x386, x387, x388, x389, x390
     &, x391, x392, x393, x394, x395, x396, x397, x398, x399, x400, x401
     &, x402, x403, x404, x405, x406, x407, x408, x409, x410, x411, x412
     &, x413, x414, x415, x416, x417, x418, x419, x420, x421, x422, x423
     &, x424, x425, x426, x427, x428, x429, x430, x431, x432, x433, x434
     &, x435, x436, x437, x438, x439, x440, x441
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      d2Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = rho_a**(-2.66666666666667d0)
      x2 = 4.60115111447049d0
      x3 = 1d0/x2
      x4 = x1*x3
      x5 = gamma_aa*x4
      x6 = mu**2
      x7 = rho_a**0.666666666666667d0
      x8 = x3*x6/x7
      x9 = 5.45136177849642d0*x8 - 7.0d0
      x10 = 0.239205142311446d0*x9
      x11 = 0.826307487110758d0
      x12 = rho_a**0.333333333333333d0
      x13 = 1d0/x12
      x14 = 21.1705915781930d0
      x15 = 1d0/x14
      x16 = mu**4
      x17 = 1d0/x0
      x18 = 59.4346904801033d0*mu*x11*x13 + 4.95289087334194d0*x15*x16*x
     &17 - 49.0622560064678d0*x8 - 81.0d0
      x19 = 1d0/x18
      x20 = x19*exp(-1.4385538026587772d0*x8)
      x21 = x10*x20*x5 + 1.0d0
      x22 = 1.804d0 - 0.804d0/x21
      x23 = 7.26848237132856d0*x22
      x24 = 0.682784063255296d0
      x25 = 2.14502939711103d0
      x26 = 1d0/x25
      x27 = x13*x26
      x28 = 0.550321208149104d0*x27
      x29 = 1d0/rho_a
      x30 = 9.86960440108936d0
      x31 = 1d0/x30
      x32 = 0.0833333333333333d0*x31
      x33 = x29*x32
      x34 = x33*x6
      x35 = x28 - x34
      x36 = exp(-3.3019272488946267d0*x2*x7/x6)
      x37 = mu*x36
      x38 = 1d0/mu
      x39 = x25*x38
      x40 = mu**3
      x41 = mu*x27
      x42 = x33*x40 - 0.825481812223657d0*x41 + 1.77245385090552d0*erf( 
     &1.8171205928321397d0*x12*x39)
      x43 = x35*x37 + x42
      x44 = 0.275160604074552d0*x41
      x45 = x43*x44 - 0.375d0
      x46 = x24*x45
      x47 = 0.682784063255296d0
      x48 = 2.72568088924821d0*x47
      x49 = exp(-4.1274090611182839d0*x41)
      x50 = 0.0206714418186455d0*x5 + 1.0d0
      x51 = 0.804d0/x50
      x52 = 0.0938662444277524d0*x5 + 1.0d0
      x53 = x52**(-2)
      x54 = 0.050475572023115d0*x5
      x55 = 1d0/gamma_aa
      x56 = tau_a*x55
      x57 = 8.0d0*rho_a*x56
      x58 = x57 - 1.0d0
      x59 = x5*x58
      x60 = 0.0567850185260044d0*x59 - 0.45d0
      x61 = 0.126188930057787d0*x59 - 1.0d0
      x62 = x58*x61
      x63 = x54*x62 + 1.0d0
      x64 = x63**(-0.5d0)
      x65 = x54 + x60*x64
      x66 = x65**2
      x67 = rho_a**(-5.33333333333333d0)*x15
      x68 = rho_a**(-2)
      x69 = tau_a**(-2)
      x70 = 0.0028125d0*x69
      x71 = 0.00286625629244325d0*x67 + x68*x70
      x72 = sqrt(x71)
      x73 = 0.00909806606836394d0*x4
      x74 = gamma_aa*x73
      x75 = x64*(0.0102353243269094d0*x59 - 0.0811111111111111d0) + x74
      x76 = x72*x75
      x77 = gamma_aa*x76
      x78 = gamma_aa**2
      x79 = x67*x78
      x80 = rho_a**(-8.0d0)
      x81 = 0.0102659822546843d0
      x82 = gamma_aa**3
      x83 = x81*x82
      x84 = x80*x83
      x85 = x68*x69
      x86 = x78*x85
      x87 = 0.015625d0*x86 + 1.0d0
      x88 = x87**(-2)
      x89 = 0.02485875d0*x86*x88 + 0.123456790123457d0
      x90 = x5*x89
      x91 = 0.000135164574498753d0*x79 + 0.000182133424673508d0*x84 + 0.
     &0021416494625995d0*x86 + 0.0941708433267071d0*x90
      x92 = x53*(0.0896750813832074d0*x66 - 1.24378109452736d0*x77 + x91
     &) + 1.0d0
      x93 = 1d0/x92
      x94 = -0.804d0*x93
      x95 = x49*(x51 + x94)
      x96 = x12*x23
      x97 = -x28 + x34
      x98 = -x37*x97 + x42
      x99 = x44*x98 - 0.375d0
      x100 = x24*x99
      x101 = -x57 + 1.0d0
      x102 = x101*x5
      x103 = 0.0567850185260044d0*x102 + 0.45d0
      x104 = 0.126188930057787d0*x102 + 1.0d0
      x105 = x101*x104
      x106 = x105*x54 + 1.0d0
      x107 = x106**(-0.5d0)
      x108 = -x103*x107 + x54
      x109 = x108**2
      x110 = x107*(0.0102353243269094d0*x102 + 0.0811111111111111d0)
      x111 = -x110 + x74
      x112 = x111*x72
      x113 = 1.24378109452736d0*x112
      x114 = x53*(-gamma_aa*x113 + 0.0896750813832074d0*x109 + x91) + 1.
     &0d0
      x115 = 1d0/x114
      x116 = -0.804d0*x115
      x117 = x12*x48
      x118 = rho_a**(-0.666666666666667d0)
      x119 = x22*x46
      x120 = x118*x119
      x121 = x2*x36*x38
      x122 = rho_a**(-0.333333333333333d0)*x121
      x123 = 2.20128483259642d0*x122
      x124 = 0.183440402716368d0*x17
      x125 = rho_a**(-2.0d0)*x32
      x126 = -x124*x26 + x125*x6
      x127 = mu*x17*x26
      x128 = x36*x39
      x129 = 1.21141372855476d0*x118*x128 - x125*x40 + x126*x37 + 0.2751
     &60604074552d0 *x127
      x130 = 0.275160604074552d0*x13
      x131 = -x130*(x123*x97 + x129) + 0.0917202013581841d0*x17*x98
      x132 = 0.318309886183791d0*mu
      x133 = x132*x96
      x134 = x132*x29
      x135 = 3.75d0*x134
      x136 = rho_a**(-4.33333333333333d0)
      x137 = x136*x15
      x138 = x137*x6
      x139 = rho_a**(-3.66666666666667d0)
      x140 = x139*x3
      x141 = x140*x9
      x142 = x138*x9
      x143 = x11*x17
      x144 = rho_a**(-1.66666666666667d0)
      x145 = x144*x3
      x146 = mu*x145
      x147 = rho_a**(-2.33333333333333d0)
      x148 = x15*x40
      x149 = x147*x148
      x150 = 19.8115634933678d0*x143 - 32.7081706709785d0*x146 + 6.60385
     &449778925d0* x149
      x151 = x150*x19
      x152 = mu*x4
      x153 = x10*x152
      x154 = -0.869329180010942d0*x138 - 0.637880379497189d0*x141 + 0.22
     &9406311391776d0*x142 + x151*x153
      x155 = x20/x21**2
      x156 = x154*x155
      x157 = 5.84385982654816d0*x12
      x158 = x156*x157
      x159 = gamma_aa*x46
      x160 = rho_a**(-3.33333333333333d0)
      x161 = 0.148394183600699d0
      x162 = x161/x50**2
      x163 = x160*x162
      x164 = -x51 + 1.804d0
      x165 = 0.90856029641607d0*x118
      x166 = x165*x47
      x167 = x92**(-2)
      x168 = 2.19144743495556d0*x12
      x169 = rho_a**(-9.0d0)
      x170 = x169*x83
      x171 = rho_a**(-6.33333333333333d0)*x15
      x172 = x171*x78
      x173 = rho_a**(-3)
      x174 = x173*x69
      x175 = x174*x78
      x176 = gamma_aa*x140
      x177 = 0.251122248871219d0*x89
      x178 = x86/x87
      x179 = 0.001553671875d0*x178
      x180 = x179 - 0.0497175d0
      x181 = x180*x82
      x182 = x69*x88
      x183 = 0.0941708433267071d0*x182
      x184 = rho_a**(-5.66666666666667d0)*x3
      x185 = x183*x184
      x186 = 0.00764335011318201d0*x171 + x173*x70
      x187 = 1d0/x72
      x188 = x187*x75
      x189 = x186*x188
      x190 = gamma_aa*x189
      x191 = 1d0/x52
      x192 = 0.000108672317896998d0*x79 + 0.0001464352734375d0*x84 + 0.0
     &0172188616792999d0*x86 + 0.0757133580346725d0*x90
      x193 = x192 + 0.0720987654320988d0*x66 - x77
      x194 = x191*x193
      x195 = 0.622661654578789d0*x194
      x196 = 0.0242615095156372d0*x140
      x197 = tau_a*x1
      x198 = x139*x58
      x199 = 0.151426716069345d0*x198
      x200 = -gamma_aa*x199 + 0.454280148208035d0*x197
      x201 = x200*x64
      x202 = 0.180246913580247d0*x3
      x203 = x3*x61
      x204 = 0.20190228809246d0*x197
      x205 = 0.0673007626974867d0*x62
      x206 = 0.336503813487433d0*x198
      x207 = x15*(-gamma_aa*x206 + 1.0095114404623d0*x197)
      x208 = x1*x58
      x209 = 0.0252377860115575d0*x208
      x210 = x207*x209
      x211 = -gamma_aa*x210 + x176*x205 - x203*x204
      x212 = x63**(-1.5d0)
      x213 = x212*x60
      x214 = x211*x213
      x215 = -gamma_aa*x196 + x201*x202 + 0.180246913580247d0*x214
      x216 = x215*x72
      x217 = gamma_aa*x216
      x218 = 0.269203050789947d0*x140
      x219 = 2.0d0*x3
      x220 = -gamma_aa*x218 + x201*x219 + 2.0d0*x214
      x221 = x220*x65
      x222 = -0.00145706739738806d0*x170 - 0.000720877730660018d0*x172 -
     & 0.00428329892519899d0*x175 - x176*x177 + x176*x195 + x181*x185 + 
     &1.24378109452736d0*x190 - 1.24378109452736d0*x217 + 0.089675081383
     &2074d0*x221
      x223 = x47*x53
      x224 = x222*x223
      x225 = x49*(0.12080100840081d0*gamma_aa*x163 - x164*x166 + x166*(x
     &94 + 1.804d0 ) + x167*x168*x224)
      x226 = x147*x161
      x227 = x226*x9
      x228 = 1.39788132145759d0*x155
      x229 = x227*x228
      x230 = x147*x162
      x231 = 0.0226501890751519d0*x230
      x232 = 2.0d0*x103
      x233 = x106**(-1.5d0)
      x234 = 0.20190228809246d0*x145
      x235 = x234*x61
      x236 = x235*x56
      x237 = x4*x61
      x238 = x237*x58
      x239 = 0.0252377860115575d0*x238
      x240 = x144*x56
      x241 = 1.0095114404623d0*x240
      x242 = 0.126188930057787d0*x1
      x243 = -x241 + x242*x58
      x244 = gamma_aa*x15
      x245 = x209*x244
      x246 = x243*x245
      x247 = -x236 + x239 + x246
      x248 = x233*x247
      x249 = 0.10095114404623d0*x4
      x250 = 0.454280148208035d0*x240
      x251 = 0.0567850185260044d0*x1
      x252 = x101*x251 + x250
      x253 = x107*x252
      x254 = -x219*x253 + x249
      x255 = x232*x248 + x254
      x256 = x108*x255
      x257 = 0.180246913580247d0*x103
      x258 = -x202*x253 + x73
      x259 = x248*x257 + x258
      x260 = gamma_aa*x72
      x261 = 1.24378109452736d0*x260
      x262 = 0.000270329148997507d0*x67
      x263 = x4*x89
      x264 = 0.00428329892519899d0*x85
      x265 = x78*x81
      x266 = x265*x80
      x267 = -gamma_aa*x112 + 0.0720987654320988d0*x109 + x192
      x268 = x191*x4
      x269 = 0.233498120467046d0*x268
      x270 = rho_a**(-4.66666666666667d0)
      x271 = x270*x3
      x272 = x271*x78
      x273 = x180*x272
      x274 = -gamma_aa*x262 - gamma_aa*x264 + x113 + x183*x273 - 0.09417
     &08433267071d0 *x263 - 0.000546400274020523d0*x266 + x267*x269
      x275 = -0.0896750813832074d0*x256 + x259*x261 + x274
      x276 = x114**(-2)
      x277 = x223*x276
      x278 = x275*x277
      x279 = 1.09572371747778d0*x12
      x280 = 2.0d0*x49
      x281 = 0.90856029641607d0*x145
      x282 = 1d0/x106
      x283 = 0.0254778337106067d0*x136
      x284 = x101*x244
      x285 = x104*x234
      x286 = x282*(x283*x284 + x285)
      x287 = 0.0720987654320988d0*x107*x108
      x288 = 0.0818825946152754d0*x145
      x289 = x107*x260
      x290 = tau_a**(-3)
      x291 = x290*x68
      x292 = gamma_aa*x291
      x293 = x187*x292
      x294 = x290*x78
      x295 = 0.0757133580346725d0*x181
      x296 = x290*x88
      x297 = x271*x295*x296 - 0.00344377233585999d0*x294*x68
      x298 = 0.0028125d0*x111*x293 + x297
      x299 = x287*(-x232*x286 + x281) - x289*(-x257*x286 + x288) + x298
      x300 = x49*x53
      x301 = x0*x276*x300
      x302 = x131*x132
      x303 = x22*x302
      x304 = x156*x159
      x305 = 11.6877196530963d0*x12
      x306 = rho_a**(-1.66666666666667d0)
      x307 = 1.27576075899438d0*x141
      x308 = x18**(-2)
      x309 = x308*exp(-2.8771076053175544d0*x8)/x21**3
      x310 = x154*x309
      x311 = x147*x26
      x312 = 0.166666666666667d0*rho_a**(-3.0d0)*x31
      x313 = x36/x40
      x314 = rho_a**(-6.0d0)
      x315 = x16*x314*x81
      x316 = x6*x67
      x317 = x137*x151*x40
      x318 = 0.0322515344331995d0
      x319 = x318/x50**3
      x320 = 0.60570686427738d0*x306*x47
      x321 = x176*x89
      x322 = x182*x184
      x323 = 1.24532330915758d0*x176
      x324 = x47/(x114**3*x52**4)
      x325 = x168*x222*x324
      x326 = rho_a**(-7.33333333333333d0)*x15
      x327 = x326*x78
      x328 = rho_a**(-4)
      x329 = x328*x69
      x330 = gamma_aa*x270
      x331 = x3*x330
      x332 = rho_a**(-6.66666666666667d0)*x3
      x333 = tau_a**(-4)
      x334 = x333*x88
      x335 = 0.00014565673828125d0*gamma_aa**4*x328*x334
      x336 = x82*(-0.010875703125d0*x178 + x335 + 0.1491525d0)
      x337 = 1.24378109452736d0*x188
      x338 = 1.24378109452736d0*gamma_aa
      x339 = x71**(-1.5d0)
      x340 = x339*x75
      x341 = x193*x53
      x342 = x186*x187
      x343 = 0.0720987654320988d0*x3
      x344 = 1.24378109452736d0*x220
      x345 = tau_a*x139
      x346 = x330*x58
      x347 = x64*(-2.42282745710952d0*x345 + 0.555231292254265d0*x346)
      x348 = 0.360493827160494d0*x3
      x349 = x211*x212
      x350 = x200*x349
      x351 = gamma_aa*x207
      x352 = x213*(-0.40380457618492d0*x197*x207 + 0.134601525394973d0*x
     &198*x351 + 1.07681220315979d0*x203*x345 - 0.246769463224118d0*x203
     &*x346 - x245*(-5.38406101579893d0*x345 + 1.23384731612059d0*x346))
     &
      x353 = 0.60570686427738d0*x61
      x354 = 0.0757133580346725d0*x208
      x355 = x211*x60
      x356 = x355*x63**(-2.5d0)
      x357 = x356*(0.20190228809246d0*x176*x62 - x197*x3*x353 - x351*x35
     &4)
      x358 = 0.00363922642734557d0*x4
      x359 = gamma_aa*x358
      x360 = x359 + x64*(0.00409412973076377d0*x59 - 0.0324444444444444d
     &0)
      x361 = 1.24378109452736d0*x360
      x362 = -0.0011714821875d0*x170 - 0.000579585695450655d0*x172 - 0.0
     &0344377233585999d0*x175 + x190 - x217 + 0.0720987654320988d0* x221
     & + x295*x322 - 0.20190228809246d0*x321
      x363 = x168*x277
      x364 = x233*(0.0252377860115575d0*x1*x284*(x101*x242 + x241) + 0.0
     &252377860115575d0*x105*x4 + x285*x56)
      x365 = -0.0896750813832074d0*x108*(x232*x364 + x254) + x261*(x257*
     &x364 + x258) + x274
      x366 = x277*x279
      x367 = gamma_aa*x67
      x368 = 0.00856659785039798d0*gamma_aa
      x369 = 0.466996240934092d0*x268
      x370 = 2.48756218905473d0*x112 + 0.188341686653414d0*x182*x273 - 0
     &.179350162766415d0*x256 + 2.48756218905473d0*x259*x260 - 0.1883416
     &86653414d0*x263 - 0.00109280054804105d0*x266 + x267*x369 - 0.00054
     &0658297995013d0*x367 - x368*x85
      x371 = gamma_aa*x171
      x372 = -x179 + 0.0497175d0
      x373 = x185*x78
      x374 = 0.00932203125d0*x178
      x375 = -x250 + x251*x58
      x376 = x375*x64
      x377 = x236 - x239 - x246
      x378 = x213*x377
      x379 = x202*x376 + 0.180246913580247d0*x378 + x73
      x380 = x338*x342
      x381 = x343*x376 + x358 + 0.0720987654320988d0*x378
      x382 = x182*x372
      x383 = x379*x72
      x384 = x219*x376 + x249 + 2.0d0*x378
      x385 = 0.0720987654320988d0*x65
      x386 = -gamma_aa*x383 + 0.00344377233585999d0*gamma_aa*x85 + 0.075
     &7133580346725d0*x263 + 0.0004393058203125d0*x266 + 0.0757133580346
     &725d0*x272*x382 + 0.000217344635793995d0*x367 + x384*x385 - x76
      x387 = 0.622661654578789d0*x176*x191
      x388 = x197*x55
      x389 = x64*(-x199 + 1.21141372855476d0*x388)
      x390 = x349*x375
      x391 = x212*x377
      x392 = x200*x202
      x393 = x145*x353
      x394 = x243*x244
      x395 = -0.0757133580346725d0*x238 - x354*x394 + x393*x56
      x396 = x356*x395
      x397 = 0.20190228809246d0*x144
      x398 = x207*x397
      x399 = x213*(x140*x205 - x15*x204*x243 + 0.0673007626974867d0*x198
     &*x394 - 0.538406101579893d0*x203*x388 - x210 - x245*(-x206 + 2.692
     &03050789947d0*x388) + x398*x56)
      x400 = x200*x219
      x401 = rho_a**(-5.0d0)
      x402 = x15*x60
      x403 = x243*x402*(-0.050475572023115d0*x208 + 0.40380457618492d0*x
     &240)
      x404 = x375*x377
      x405 = 1d0/x63
      x406 = x405*x60
      x407 = x377*x395*x406
      x408 = x283*x58
      x409 = x235 + x244*x408
      x410 = x282*x409
      x411 = x232*x410 + x281
      x412 = x257*x410 + x288
      x413 = x287*x411 - x289*x412 + x298
      x414 = x406*x409
      x415 = 2.0d0*x414
      x416 = 0.180246913580247d0*x414
      x417 = x64*(x288 - x416)
      x418 = 0.0028125d0*x188*x292 - x260*x417 + x297 + x385*x64*(x281 -
     & x415)
      x419 = x184*x296
      x420 = x335 - x374 + 0.099435d0
      x421 = 0.0327530378461102d0*x145
      x422 = x405*x409
      x423 = x406*(-0.203822669684853d0*tau_a*x137 + 0.336503813487433d0
     &*x237 + 0.110403946079296d0*x367*x58 - x398)
      x424 = x211*x405
      x425 = 0.0764335011318201d0*gamma_aa*x137*x58 + x393
      x426 = x355*x425/x63**2
      x427 = 0.103185226527957d0*x271*x294*x88
      x428 = 1.3628404446241d0*x187*x291
      x429 = 1.3628404446241d0*x107
      x430 = 0.0720987654320988d0*x103*x410 + x421
      x431 = x252*x409
      x432 = x15*(-0.203822669684853d0*x160*x56 + x243*x397 + x408)
      x433 = x247*x282*x425
      x434 = 1.3628404446241d0*x233
      x435 = -x107*(0.00409412973076377d0*x102 + 0.0324444444444444d0) +
     & x359
      x436 = x115*x53
      x437 = x333*x68
      x438 = gamma_aa*x111
      x439 = x160*x402
      x440 = x145*x409
      x441 = 2.72568088924821d0*x212
      Ea = -x0*(-x23*x46 + x48*x95)
      d1Ea(1) = -rho_a*(-2.42282745710952d0*x120 + x131*x133 + x135*x95 
     &- x158*x159 + x225) + x100*x96 - x117*x49*(x116 + x51)
      d1Ea(2) = rho_a*(x229*x45 + x280*(x231 + x278*x279))
      d1Ea(3) = -x299*x301*x48
      d2Ea(1) = rho_a*(-gamma_aa*x156*x302*x305 + 5.0d0*rho_a**(-2.0d0)*
     &x132*x95 - 4.84565491421904d0*x118*x303 + 3.89590655103211d0*x118*
     &x304 - 1.61521830473968d0*x119*x306 - 2.75160604074552d0*x127*x225
     & + x133*(-x124*(-x123*x35 + x129) + x130*(-0.366880805432736d0*mu*
     & x311 + 0.733761610865473d0*rho_a**(-1.33333333333333d0)*x121*x35 
     &+ 4.84565491421904d0*x118*x14*x313*x35 - 4.40256966519284d0*x122* 
     &x126 - 0.80760915236984d0*x128*x306 - 2.66666666666667d0*x29*x30* 
     &x313 + x312*x40 + x37*(0.244587203621824d0*x311 - x312*x6)) + 0.12
     &2293601810912d0*x147*x43) + x155*x157*x159*(-mu*x151*x307 + x10*x1
     &50*x308*x4*x6*(39.6231269867355d0*x143 - 65.416341341957d0* x146 +
     & 13.2077089955785d0*x149) + x153*x19*(-26.415417991157d0* x11*x147
     & - 15.4089938281749d0*x148*x160 + 54.5136177849642d0*x152 ) + 2.33
     &889472482303d0*x271*x9 + 0.220008881071042d0*x315*x9 - 1.667435730
     &22264d0*x315 - 1.60584417974243d0*x316*x9 + 6.08530426007659d0*x31
     &6 + 0.458812622783553d0*x317*x9 - 1.73865836002188d0*x317) - x157*
     &x310*x46*x78*(-1.73865836002188d0 *x138 + 0.458812622783553d0*x142
     & + 0.478410284622892d0*x151*x152* x9 - x307) - 5.15926132639785d0*
     &x226*x6*x95 + x49*( 0.36240302520243d0*gamma_aa*x136*x162 - 0.0133
     &180320895522d0* rho_a**(-7.0d0)*x319*x78 - 1.46096495663704d0*x118
     &*x224*x276 - x164*x320 + x320*(x116 + 1.804d0) + x325*(-0.00291413
     &479477612d0* x170 - 0.00144175546132004d0*x172 - 0.008566597850397
     &98d0*x175 + 0.188341686653414d0*x181*x322 + 2.48756218905473d0*x19
     &0 + x194* x323 - 2.48756218905473d0*x217 + 0.179350162766415d0*x22
     &1 - 0.502244497742438d0*x321) - x363*(2.48756218905473d0*gamma_aa*
     & x215*x342 - gamma_aa*x337*(0.0484078840501527d0*x326 + 0.0084375d
     &0*x329) + 0.0131136065764925d0*rho_a**(-10.0d0)*x83 - 0.5022444977
     &42438d0*x181*x182*x332 + x183*x332*x336 + x186**2* x338*x340 + x19
     &1*x323*x362 - 2.28309273345556d0*x194*x331 - x261* (x202*x347 + 0.
     &0889588682240029d0*x331 + x348*x350 + 0.180246913580247d0*x352 + 0
     &.180246913580247d0*x357) + 0.46757528851585d0*x327*x341 + 0.004565
     &55896084678d0*x327 + 0.012849896775597d0*x329*x78 + 0.920781579194
     &469d0*x331*x89 + x344*(-0.00970460380625487d0*x176 + x201*x343 + 0
     &.0720987654320988d0*x214) + x361*(x219*x347 + 4.0d0*x3*x350 + 0.98
     &7077852896471d0*x331 + 2.0d0*x352 + 2.0d0*x357)))) - 14.5369647426
     &571d0*x12*x303 + 4.84565491421904d0*x120 - 7.5d0* x134*x95 - 2.0d0
     &*x225 + x304*x305
      d2Ea(2) = rho_a*(-2.79576264291519d0*gamma_aa*x227*x310*x99 - 0.06
     &91804894611514d0 *mu*x131*x147*x228*x9 + x100*x158 + 1.37580302037
     &276d0*x127*x49*( 0.0453003781503037d0*x230 + x363*x365) + 0.465960
     &440485865d0*x155 *x160*x161*x9*x99 - x49*(-0.00499426203358209d0*g
     &amma_aa*x314* x319 - 0.73048247831852d0*x118*x278 + 0.105700882350
     &709d0*x163 + x325*x370 + x363*(-x140*x177 + x140*x195 - 0.00437120
     &219216418d0* x169*x265 - x174*x368 + x180*x373 - 1.24378109452736d
     &0*x189 - 1.24378109452736d0*x216 - x261*(-x196 + x202*x389 + x202*
     &x390 + x391*x392 + 0.180246913580247d0*x396 + 0.180246913580247d0*
     &x399) - x269*x362 - 0.251122248871219d0*x322*x372*x78 + x337*( 0.0
     &15286700226364d0*x171 + 0.005625d0*x174) - 0.175340733193444d0 *x3
     &41*x371 + x344*x381 + x361*(-x218 + x219*x389 + x219*x390 + x391*x
     &400 + 2.0d0*x396 + 2.0d0*x399) - 0.00144175546132004d0*x371 + x373
     &*(-x335 + x374 - 0.099435d0) + x379*x380 + x386*x387))) + x229*x99
     & + x280*(x231 + x365*x366)
      d2Ea(3) = -rho_a*(-x280*(x275*x279*x324*x370 - 0.00093642413129664
     &2d0*x319*x401 - x366*(0.00109280054804105d0*gamma_aa*x80*x81 + x18
     &3*x331*( -0.007768359375d0*x178 + x335 + 0.0497175d0) - x212*x261*
     &(x348* x404 + 0.180246913580247d0*x403 + 0.180246913580247d0*x407)
     & + 2.48756218905473d0*x212*x360*(x219*x404 + x403 + x407) + x262 +
     & x264 + 0.188341686653414d0*x331*x382 + 0.0657527749475415d0*x341*
     & x67 - x369*x386 + 1.24378109452736d0*x381*x384 - 2.48756218905473
     &d0*x383)) + 0.668760800867552d0*x309*x318*x401* x45*x9**2)
      d2Ea(4) = -x300*(rho_a*x167*(x135*x418 - x47*(5.45136177849642d0*x
     &12*x222*x418*x53 *x93 - x165*x418 - x168*(-0.00699626865671642d0*g
     &amma_aa*x173* x188*x290 + 0.00856659785039798d0*x173*x294 - 0.2511
     &22248871219d0 *x181*x419 + 0.00349813432835821d0*x186*x292*x340 + 
     &0.00349813432835821d0*x215*x293 - x261*x64*(x288*x424 - x392*x422 
     &- 0.136470991025459d0*x4 + 0.180246913580247d0*x423 - 0.1802469135
     &80247d0*x426) + x344*x64*(-0.0720987654320988d0*x414 + x421) + x36
     &1*x64*(x281*x424 - 1.51426716069345d0*x4 - x400*x422 + 2.0d0*x423 
     &- 2.0d0*x426) + x380*x417 + x387*x418 + 0.0941708433267071d0*x419*
     &x420*x82))) + x117*x276*x413)
      d2Ea(5) = x0*x277*x280*(-x180*x427 - x255*x429*x430 - 0.0038329887
     &5050529d0*x259* x293 + x260*x434*(x202*x431 - x247*x288 + x257*x43
     &2 - x257*x433) + 0.255849428582226d0*x268*x299 + 0.009386624442775
     &24d0*x292 - 2.72568088924821d0*x299*x365*x436 + x412*x429*x72 + x4
     &20*x427 - x428*(-0.005625d0*x110 + 5.11766216345471d-5*x5) + x428*
     &( -0.0028125d0*x110 + 2.55883108172736d-5*x5) - x434*x435*(x219* x
     &431 + x232*x432 - x232*x433 - x247*x281))
      d2Ea(6) = x301*x47*(-0.0153319550020212d0*x107*x293*x412 + 0.02299
     &79325030318d0* x187*x437*x438 - x260*x441*(-x416*x425 + 0.07347681
     &4256762d0*x439 + 0.163765189230551d0*x440) - 0.206370453055914d0*x
     &271*x334*x336 - 2.72568088924821d0*x282*x411*x430 + 6.780300719522
     &91d0*x413**2* x436 + x435*x441*(-x415*x425 + 0.815290678739414d0*x
     &439 + 1.81712059283214d0*x440) - 0.0281598733283257d0*x437*x78 - 2
     &.15605617215923d-5*x328*x339*x438/tau_a**6)
      end subroutine


C*****************************************************************************
      pure subroutine D2ESRX_TPSS_GWS_ERF_case_2_2(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea, d2Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4), d2Ea(10)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168, x169, x170
     &, x171, x172, x173, x174, x175, x176, x177, x178, x179, x180, x181
     &, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192
     &, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203
     &, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, x214
     &, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225
     &, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236
     &, x237, x238, x239, x240, x241, x242, x243, x244, x245, x246, x247
     &, x248, x249, x250, x251, x252, x253, x254, x255, x256, x257, x258
     &, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269
     &, x270, x271, x272, x273, x274, x275, x276, x277, x278, x279, x280
     &, x281, x282, x283, x284, x285, x286, x287, x288, x289, x290, x291
     &, x292, x293, x294, x295, x296, x297, x298, x299, x300, x301, x302
     &, x303, x304, x305, x306, x307, x308, x309, x310, x311, x312, x313
     &, x314, x315, x316, x317, x318, x319, x320, x321, x322, x323, x324
     &, x325, x326, x327, x328, x329, x330, x331, x332, x333, x334, x335
     &, x336, x337, x338, x339, x340, x341, x342, x343, x344, x345, x346
     &, x347, x348, x349, x350, x351, x352, x353, x354, x355, x356, x357
     &, x358, x359, x360, x361, x362, x363, x364, x365, x366, x367, x368
     &, x369, x370, x371, x372, x373, x374, x375, x376, x377, x378, x379
     &, x380, x381, x382, x383, x384, x385, x386, x387, x388, x389, x390
     &, x391, x392, x393, x394, x395, x396, x397, x398, x399, x400, x401
     &, x402, x403, x404, x405, x406, x407, x408, x409, x410, x411, x412
     &, x413, x414, x415, x416, x417, x418, x419, x420, x421, x422, x423
     &, x424, x425, x426, x427, x428, x429, x430, x431, x432, x433, x434
     &, x435, x436, x437, x438, x439, x440, x441, x442, x443, x444, x445
     &, x446, x447, x448, x449, x450, x451
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      d2Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = 7.26848237132856d0*x1
      x3 = rho_a**(-2.66666666666667d0)
      x4 = 4.60115111447049d0
      x5 = 1d0/x4
      x6 = x3*x5
      x7 = gamma_aa*x6
      x8 = mu**2
      x9 = rho_a**0.666666666666667d0
      x10 = x5*x8/x9
      x11 = exp(-1.4385538026587772d0*x10)
      x12 = 1d0/x8
      x13 = x4*x9
      x14 = 0.183440402716368d0*x13
      x15 = 21.1705915781930d0
      x16 = x12*x15
      x17 = 0.010095114404623d0*x0*x16
      x18 = rho_a**2.0d0
      x19 = 97.4090910340024d0
      x20 = mu**(-4)
      x21 = x19*x20
      x22 = 0.147857142857143d0*x18*x21
      x23 = -x14 + x17 + x22
      x24 = x12*x23
      x25 = x11*x24
      x26 = 0.239205142311446d0*x25*x7
      x27 = -x26 + 1.0d0
      x28 = 1.804d0 - 0.804d0/x27
      x29 = 2.14502939711103d0
      x30 = 1d0/x29
      x31 = rho_a**0.333333333333333d0
      x32 = 1d0/x31
      x33 = x30*x32
      x34 = 0.550321208149104d0*x33
      x35 = rho_a**1.0d0
      x36 = 1d0/x35
      x37 = 9.86960440108936d0
      x38 = 1d0/x37
      x39 = 0.0833333333333333d0*x38
      x40 = x36*x39
      x41 = x40*x8
      x42 = x34 - x41
      x43 = exp(-3.3019272488946267d0*x12*x13)
      x44 = mu*x43
      x45 = 1d0/mu
      x46 = x29*x45
      x47 = mu**3
      x48 = mu*x33
      x49 = x40*x47 - 0.825481812223657d0*x48 + 1.77245385090552d0*erf( 
     &1.8171205928321397d0*x31*x46)
      x50 = x42*x44 + x49
      x51 = 0.275160604074552d0*x48
      x52 = x50*x51 - 0.375d0
      x53 = x28*x52
      x54 = 0.682784063255296d0
      x55 = 2.72568088924821d0*x54
      x56 = exp(-4.1274090611182839d0*x48)
      x57 = 0.0206714418186455d0*x7 + 1.0d0
      x58 = 0.804d0/x57
      x59 = 0.0938662444277524d0*x7 + 1.0d0
      x60 = x59**(-2)
      x61 = 0.050475572023115d0*x7
      x62 = 1d0/gamma_aa
      x63 = tau_a*x62
      x64 = 8.0d0*rho_a*x63
      x65 = x64 - 1.0d0
      x66 = x65*x7
      x67 = 0.0567850185260044d0*x66 - 0.45d0
      x68 = 0.126188930057787d0*x66 - 1.0d0
      x69 = x65*x68
      x70 = x61*x69 + 1.0d0
      x71 = x70**(-0.5d0)
      x72 = x61 + x67*x71
      x73 = x72**2
      x74 = 1d0/x15
      x75 = rho_a**(-5.33333333333333d0)*x74
      x76 = rho_a**(-2)
      x77 = tau_a**(-2)
      x78 = 0.0028125d0*x77
      x79 = 0.00286625629244325d0*x75 + x76*x78
      x80 = sqrt(x79)
      x81 = 0.00909806606836394d0*x6
      x82 = gamma_aa*x81
      x83 = x71*(0.0102353243269094d0*x66 - 0.0811111111111111d0) + x82
      x84 = x80*x83
      x85 = gamma_aa*x84
      x86 = gamma_aa**2
      x87 = x75*x86
      x88 = rho_a**(-8.0d0)
      x89 = 1d0/x19
      x90 = gamma_aa**3
      x91 = x89*x90
      x92 = x88*x91
      x93 = x76*x77
      x94 = x86*x93
      x95 = 0.015625d0*x94 + 1.0d0
      x96 = x95**(-2)
      x97 = 0.02485875d0*x94*x96 + 0.123456790123457d0
      x98 = x7*x97
      x99 = 0.000135164574498753d0*x87 + 0.000182133424673508d0*x92 + 0.
     &0021416494625995d0*x94 + 0.0941708433267071d0*x98
      x100 = x60*(0.0896750813832074d0*x73 - 1.24378109452736d0*x85 + x9
     &9) + 1.0d0
      x101 = 1d0/x100
      x102 = -0.804d0*x101
      x103 = x56*(x102 + x58)
      x104 = x26 - 1.0d0
      x105 = -x34 + x41
      x106 = -x105*x44 + x49
      x107 = x106*x51 - 0.375d0
      x108 = x107*x31
      x109 = -x64 + 1.0d0
      x110 = x109*x7
      x111 = 0.0567850185260044d0*x110 + 0.45d0
      x112 = 0.126188930057787d0*x110 + 1.0d0
      x113 = x109*x112
      x114 = x113*x61 + 1.0d0
      x115 = x114**(-0.5d0)
      x116 = -x111*x115 + x61
      x117 = x116**2
      x118 = x115*(0.0102353243269094d0*x110 + 0.0811111111111111d0)
      x119 = -x118 + x82
      x120 = x119*x80
      x121 = 1.24378109452736d0*x120
      x122 = x60*(-gamma_aa*x121 + 0.0896750813832074d0*x117 + x99) + 1.
     &0d0
      x123 = 1d0/x122
      x124 = -0.804d0*x123
      x125 = x31*x55
      x126 = rho_a**(-0.666666666666667d0)
      x127 = x1*x53
      x128 = x126*x127
      x129 = 1d0/x0
      x130 = rho_a**(-0.333333333333333d0)*x4
      x131 = x43*x45
      x132 = x130*x131
      x133 = 2.20128483259642d0*x132
      x134 = 0.183440402716368d0*x129
      x135 = x39/x18
      x136 = -x134*x30 + x135*x8
      x137 = mu*x129*x30
      x138 = x43*x46
      x139 = 1.21141372855476d0*x126*x138 - x135*x47 + x136*x44 + 0.2751
     &60604074552d0 *x137
      x140 = 0.275160604074552d0*x32
      x141 = 0.0917202013581841d0*x106*x129 - x140*(x105*x133 + x139)
      x142 = 0.318309886183791d0*mu
      x143 = x141*x142*x28
      x144 = 7.26848237132856d0*x31
      x145 = x14 - x17 - x22
      x146 = rho_a**(-4.33333333333333d0)
      x147 = x146*x74
      x148 = x145*x147
      x149 = rho_a**(-3.66666666666667d0)
      x150 = x149*x5
      x151 = x12*x145
      x152 = x150*x151
      x153 = 0.122293601810912d0*x130
      x154 = 0.0134601525394973d0*rho_a**0.333333333333333d0*x16
      x155 = 0.295714285714286d0*x21
      x156 = x155*x35
      x157 = x153 - x154 - x156
      x158 = x12*x157
      x159 = 0.239205142311446d0*x6
      x160 = 0.229406311391776d0*x148 - 0.637880379497189d0*x152 + x158*
     &x159
      x161 = x160*x31
      x162 = x1*x11
      x163 = 5.84385982654816d0*x162
      x164 = x27**(-2)
      x165 = x164*x52
      x166 = gamma_aa*x165
      x167 = x163*x166
      x168 = x142*x36
      x169 = 3.75d0*x168
      x170 = rho_a**(-3.33333333333333d0)
      x171 = 0.148394183600699d0
      x172 = x171/x57**2
      x173 = x170*x172
      x174 = -x58 + 1.804d0
      x175 = 0.90856029641607d0*x126
      x176 = x175*x54
      x177 = x100**(-2)
      x178 = 2.19144743495556d0*x31
      x179 = rho_a**(-9.0d0)
      x180 = x179*x91
      x181 = rho_a**(-6.33333333333333d0)*x74
      x182 = x181*x86
      x183 = rho_a**(-3)
      x184 = x183*x77
      x185 = x184*x86
      x186 = gamma_aa*x150
      x187 = 0.251122248871219d0*x97
      x188 = x94/x95
      x189 = 0.001553671875d0*x188
      x190 = x189 - 0.0497175d0
      x191 = x190*x90
      x192 = x77*x96
      x193 = 0.0941708433267071d0*x192
      x194 = rho_a**(-5.66666666666667d0)*x5
      x195 = x193*x194
      x196 = 0.00764335011318201d0*x181 + x183*x78
      x197 = 1d0/x80
      x198 = x197*x83
      x199 = x196*x198
      x200 = gamma_aa*x199
      x201 = 1d0/x59
      x202 = 0.000108672317896998d0*x87 + 0.0001464352734375d0*x92 + 0.0
     &0172188616792999d0*x94 + 0.0757133580346725d0*x98
      x203 = x202 + 0.0720987654320988d0*x73 - x85
      x204 = x201*x203
      x205 = 0.622661654578789d0*x204
      x206 = 0.0242615095156372d0*x150
      x207 = tau_a*x3
      x208 = x149*x65
      x209 = 0.151426716069345d0*x208
      x210 = -gamma_aa*x209 + 0.454280148208035d0*x207
      x211 = x210*x71
      x212 = 0.180246913580247d0*x5
      x213 = x5*x68
      x214 = 0.20190228809246d0*x207
      x215 = 0.0673007626974867d0*x69
      x216 = 0.336503813487433d0*x208
      x217 = x74*(-gamma_aa*x216 + 1.0095114404623d0*x207)
      x218 = x3*x65
      x219 = 0.0252377860115575d0*x218
      x220 = x217*x219
      x221 = -gamma_aa*x220 + x186*x215 - x213*x214
      x222 = x70**(-1.5d0)
      x223 = x222*x67
      x224 = x221*x223
      x225 = -gamma_aa*x206 + x211*x212 + 0.180246913580247d0*x224
      x226 = x225*x80
      x227 = gamma_aa*x226
      x228 = 0.269203050789947d0*x150
      x229 = 2.0d0*x5
      x230 = -gamma_aa*x228 + x211*x229 + 2.0d0*x224
      x231 = x230*x72
      x232 = -0.00145706739738806d0*x180 - 0.000720877730660018d0*x182 -
     & 0.00428329892519899d0*x185 - x186*x187 + x186*x205 + x191*x195 + 
     &1.24378109452736d0*x200 - 1.24378109452736d0*x227 + 0.089675081383
     &2074d0*x231
      x233 = x54*x60
      x234 = x232*x233
      x235 = x56*(0.12080100840081d0*gamma_aa*x173 - x174*x176 + x176*(x
     &102 + 1.804d0 ) + x177*x178*x234)
      x236 = rho_a**(-2.33333333333333d0)
      x237 = x171*x236
      x238 = 1.39788132145759d0*x237*x25
      x239 = x172*x236
      x240 = 0.0226501890751519d0*x239
      x241 = 2.0d0*x111
      x242 = x114**(-1.5d0)
      x243 = rho_a**(-1.66666666666667d0)
      x244 = x243*x5
      x245 = 0.20190228809246d0*x244
      x246 = x245*x68
      x247 = x246*x63
      x248 = x6*x68
      x249 = x248*x65
      x250 = 0.0252377860115575d0*x249
      x251 = x243*x63
      x252 = 1.0095114404623d0*x251
      x253 = 0.126188930057787d0*x3
      x254 = -x252 + x253*x65
      x255 = gamma_aa*x74
      x256 = x219*x255
      x257 = x254*x256
      x258 = -x247 + x250 + x257
      x259 = x242*x258
      x260 = 0.10095114404623d0*x6
      x261 = 0.454280148208035d0*x251
      x262 = 0.0567850185260044d0*x3
      x263 = x109*x262 + x261
      x264 = x115*x263
      x265 = -x229*x264 + x260
      x266 = x241*x259 + x265
      x267 = x116*x266
      x268 = 0.180246913580247d0*x111
      x269 = -x212*x264 + x81
      x270 = x259*x268 + x269
      x271 = gamma_aa*x80
      x272 = 1.24378109452736d0*x271
      x273 = 0.000270329148997507d0*x75
      x274 = x6*x97
      x275 = 0.00428329892519899d0*x93
      x276 = x86*x89
      x277 = x276*x88
      x278 = -gamma_aa*x120 + 0.0720987654320988d0*x117 + x202
      x279 = x201*x6
      x280 = 0.233498120467046d0*x279
      x281 = rho_a**(-4.66666666666667d0)
      x282 = x281*x5
      x283 = x282*x86
      x284 = x190*x283
      x285 = -gamma_aa*x273 - gamma_aa*x275 + x121 + x193*x284 - 0.09417
     &08433267071d0 *x274 - 0.000546400274020523d0*x277 + x278*x280
      x286 = -0.0896750813832074d0*x267 + x270*x272 + x285
      x287 = x122**(-2)
      x288 = x233*x287
      x289 = x286*x288
      x290 = 1.09572371747778d0*x31
      x291 = 2.0d0*x56
      x292 = 0.90856029641607d0*x244
      x293 = 1d0/x114
      x294 = 0.0254778337106067d0*x146
      x295 = x109*x255
      x296 = x112*x245
      x297 = x293*(x294*x295 + x296)
      x298 = 0.0720987654320988d0*x115*x116
      x299 = 0.0818825946152754d0*x244
      x300 = x115*x271
      x301 = tau_a**(-3)
      x302 = x301*x76
      x303 = gamma_aa*x302
      x304 = x197*x303
      x305 = x301*x86
      x306 = 0.0757133580346725d0*x191
      x307 = x301*x96
      x308 = x282*x306*x307 - 0.00344377233585999d0*x305*x76
      x309 = 0.0028125d0*x119*x304 + x308
      x310 = x298*(-x241*x297 + x292) - x300*(-x268*x297 + x299) + x309
      x311 = x56*x60
      x312 = x0*x287*x311
      x313 = x162*x166
      x314 = 11.6877196530963d0*x161
      x315 = rho_a**(-1.66666666666667d0)
      x316 = rho_a**(-1.33333333333333d0)*x4
      x317 = x12*x159
      x318 = rho_a**(-6.0d0)
      x319 = x11*x141
      x320 = exp(-2.8771076053175544d0*x10)
      x321 = x320*x52/x27**3
      x322 = x236*x30
      x323 = 0.166666666666667d0*rho_a**(-3.0d0)*x38
      x324 = x43/x47
      x325 = 0.0322515344331995d0
      x326 = x325/x57**3
      x327 = 0.60570686427738d0*x315*x54
      x328 = x186*x97
      x329 = x192*x194
      x330 = 1.24532330915758d0*x186
      x331 = x54/(x122**3*x59**4)
      x332 = x178*x232*x331
      x333 = rho_a**(-7.33333333333333d0)*x74
      x334 = x333*x86
      x335 = rho_a**(-4)
      x336 = x335*x77
      x337 = gamma_aa*x281
      x338 = x337*x5
      x339 = rho_a**(-6.66666666666667d0)*x5
      x340 = tau_a**(-4)
      x341 = x340*x96
      x342 = 0.00014565673828125d0*gamma_aa**4*x335*x341
      x343 = x90*(-0.010875703125d0*x188 + x342 + 0.1491525d0)
      x344 = 1.24378109452736d0*x198
      x345 = 1.24378109452736d0*gamma_aa
      x346 = x79**(-1.5d0)
      x347 = x346*x83
      x348 = x203*x60
      x349 = x196*x197
      x350 = 0.0720987654320988d0*x5
      x351 = 1.24378109452736d0*x230
      x352 = tau_a*x149
      x353 = x337*x65
      x354 = x71*(-2.42282745710952d0*x352 + 0.555231292254265d0*x353)
      x355 = 0.360493827160494d0*x5
      x356 = x221*x222
      x357 = x210*x356
      x358 = gamma_aa*x217
      x359 = x223*(-0.40380457618492d0*x207*x217 + 0.134601525394973d0*x
     &208*x358 + 1.07681220315979d0*x213*x352 - 0.246769463224118d0*x213
     &*x353 - x256*(-5.38406101579893d0*x352 + 1.23384731612059d0*x353))
     &
      x360 = 0.60570686427738d0*x68
      x361 = 0.0757133580346725d0*x218
      x362 = x221*x67
      x363 = x362*x70**(-2.5d0)
      x364 = x363*(0.20190228809246d0*x186*x69 - x207*x360*x5 - x358*x36
     &1)
      x365 = 0.00363922642734557d0*x6
      x366 = gamma_aa*x365
      x367 = x366 + x71*(0.00409412973076377d0*x66 - 0.0324444444444444d
     &0)
      x368 = 1.24378109452736d0*x367
      x369 = -0.0011714821875d0*x180 - 0.000579585695450655d0*x182 - 0.0
     &0344377233585999d0*x185 + x200 - x227 + 0.0720987654320988d0* x231
     & + x306*x329 - 0.20190228809246d0*x328
      x370 = x178*x288
      x371 = x104**(-2)
      x372 = x107*x371
      x373 = x242*(0.0252377860115575d0*x113*x6 + 0.0252377860115575d0*x
     &295*x3*(x109* x253 + x252) + x296*x63)
      x374 = -0.0896750813832074d0*x116*(x241*x373 + x265) + x272*(x268*
     &x373 + x269) + x285
      x375 = x288*x290
      x376 = -0.229406311391776d0*x147*x23 + 0.637880379497189d0*x150*x2
     &4 - x317*( -x153 + x154 + x156)
      x377 = gamma_aa*x75
      x378 = 0.00856659785039798d0*gamma_aa
      x379 = 0.466996240934092d0*x279
      x380 = 2.48756218905473d0*x120 + 0.188341686653414d0*x192*x284 - 0
     &.179350162766415d0*x267 + 2.48756218905473d0*x270*x271 - 0.1883416
     &86653414d0*x274 - 0.00109280054804105d0*x277 + x278*x379 - 0.00054
     &0658297995013d0*x377 - x378*x93
      x381 = gamma_aa*x181
      x382 = -x189 + 0.0497175d0
      x383 = x195*x86
      x384 = 0.00932203125d0*x188
      x385 = -x261 + x262*x65
      x386 = x385*x71
      x387 = x247 - x250 - x257
      x388 = x223*x387
      x389 = x212*x386 + 0.180246913580247d0*x388 + x81
      x390 = x345*x349
      x391 = x350*x386 + x365 + 0.0720987654320988d0*x388
      x392 = x192*x382
      x393 = x389*x80
      x394 = x229*x386 + x260 + 2.0d0*x388
      x395 = 0.0720987654320988d0*x72
      x396 = -gamma_aa*x393 + 0.00344377233585999d0*gamma_aa*x93 + 0.075
     &7133580346725d0*x274 + 0.0004393058203125d0*x277 + 0.0757133580346
     &725d0*x283*x392 + 0.000217344635793995d0*x377 + x394*x395 - x84
      x397 = 0.622661654578789d0*x186*x201
      x398 = x207*x62
      x399 = x71*(-x209 + 1.21141372855476d0*x398)
      x400 = x356*x385
      x401 = x222*x387
      x402 = x210*x212
      x403 = x244*x360
      x404 = x254*x255
      x405 = -0.0757133580346725d0*x249 - x361*x404 + x403*x63
      x406 = x363*x405
      x407 = 0.20190228809246d0*x243
      x408 = x217*x407
      x409 = x223*(x150*x215 + 0.0673007626974867d0*x208*x404 - 0.538406
     &101579893d0* x213*x398 - x214*x254*x74 - x220 - x256*(-x216 + 2.69
     &203050789947d0*x398) + x408*x63)
      x410 = x210*x229
      x411 = rho_a**(-5.0d0)
      x412 = x67*x74
      x413 = x254*x412*(-0.050475572023115d0*x218 + 0.40380457618492d0*x
     &251)
      x414 = x385*x387
      x415 = 1d0/x70
      x416 = x415*x67
      x417 = x387*x405*x416
      x418 = x294*x65
      x419 = x246 + x255*x418
      x420 = x293*x419
      x421 = x241*x420 + x292
      x422 = x268*x420 + x299
      x423 = x298*x421 - x300*x422 + x309
      x424 = x416*x419
      x425 = 2.0d0*x424
      x426 = 0.180246913580247d0*x424
      x427 = x71*(x299 - x426)
      x428 = 0.0028125d0*x198*x303 - x271*x427 + x308 + x395*x71*(x292 -
     & x425)
      x429 = x194*x307
      x430 = x342 - x384 + 0.099435d0
      x431 = 0.0327530378461102d0*x244
      x432 = x415*x419
      x433 = x416*(-0.203822669684853d0*tau_a*x147 + 0.336503813487433d0
     &*x248 + 0.110403946079296d0*x377*x65 - x408)
      x434 = x221*x415
      x435 = 0.0764335011318201d0*gamma_aa*x147*x65 + x403
      x436 = x362*x435/x70**2
      x437 = 0.103185226527957d0*x282*x305*x96
      x438 = 1.3628404446241d0*x197*x302
      x439 = 1.3628404446241d0*x115
      x440 = 0.0720987654320988d0*x111*x420 + x431
      x441 = x263*x419
      x442 = x74*(-0.203822669684853d0*x170*x63 + x254*x407 + x418)
      x443 = x258*x293*x435
      x444 = 1.3628404446241d0*x242
      x445 = -x115*(0.00409412973076377d0*x110 + 0.0324444444444444d0) +
     & x366
      x446 = x123*x60
      x447 = x340*x76
      x448 = gamma_aa*x119
      x449 = x170*x412
      x450 = x244*x419
      x451 = 2.72568088924821d0*x222
      Ea = -x0*(x103*x55 - x2*x53)
      d1Ea(1) = -rho_a*(x103*x169 - 2.42282745710952d0*x128 + x143*x144 
     &- x161*x167 + x235) + x108*x2*(1.804d0 + 0.804d0/x104) - x125*x56*
     &(x124 + x58)
      d1Ea(2) = -rho_a*(x165*x238 - x291*(x240 + x289*x290))
      d1Ea(3) = -x310*x312*x55
      d2Ea(1) = rho_a*(-gamma_aa*x142*x164*x314*x319 + 5.0d0*rho_a**(-2.
     &0d0)*x103*x142 - 5.84385982654816d0*x1*x161*x321*x86*(0.4588126227
     &83553d0*x148 - 1.27576075899438d0*x152 + 0.478410284622892d0*x158*
     &x6) - 5.15926132639785d0*x103*x237*x8 - 4.84565491421904d0*x126*x1
     &43 + 3.89590655103211d0*x126*x160*x313 - 1.61521830473968d0*x127*x
     &315 - 2.75160604074552d0*x137*x235 + x142*x144*x28*(-x134*(-x133*x
     &42 + x139) + x140*(-0.366880805432736d0*mu*x322 + 4.84565491421904
     &d0 *x126*x15*x324*x42 + 0.733761610865473d0*x131*x316*x42 - 4.4025
     &6966519284d0*x132*x136 - 0.80760915236984d0*x138*x315 + x323*x47 -
     & 2.66666666666667d0*x324*x36*x37 + x44*( 0.244587203621824d0*x322 
     &- x323*x8)) + 0.122293601810912d0*x236* x50) + x167*x31*(0.2200088
     &81071042d0*x145*x318*x8*x89 - 1.60584417974243d0*x145*x75 + 0.4588
     &12622783553d0*x147*x157 - 1.27576075899438d0*x150*x158 + 2.3388947
     &2482303d0*x151*x282 - x317*(0.00448671751316577d0*x126*x16 + x155 
     &+ 0.0407645339369707d0*x316)) + x56*(0.36240302520243d0*gamma_aa* 
     &x146*x172 - 0.0133180320895522d0*rho_a**(-7.0d0)*x326*x86 - 1.4609
     &6495663704d0*x126*x234*x287 - x174*x327 + x327*(x124 + 1.804d0) + 
     &x332*(-0.00291413479477612d0*x180 - 0.00144175546132004d0*x182 - 0
     &.00856659785039798d0*x185 + 0.188341686653414d0*x191*x329 + 2.4875
     &6218905473d0*x200 + x204* x330 - 2.48756218905473d0*x227 + 0.17935
     &0162766415d0*x231 - 0.502244497742438d0*x328) - x370*(2.4875621890
     &5473d0*gamma_aa* x225*x349 - gamma_aa*x344*(0.0484078840501527d0*x
     &333 + 0.0084375d0*x336) + 0.0131136065764925d0*rho_a**(-10.0d0)*x9
     &1 - 0.502244497742438d0*x191*x192*x339 + x193*x339*x343 + x196**2*
     & x345*x347 + x201*x330*x369 - 2.28309273345556d0*x204*x338 - x272*
     & (x212*x354 + 0.0889588682240029d0*x338 + x355*x357 + 0.1802469135
     &80247d0*x359 + 0.180246913580247d0*x364) + 0.46757528851585d0*x334
     &*x348 + 0.00456555896084678d0*x334 + 0.012849896775597d0*x336*x86 
     &+ 0.920781579194469d0*x338*x97 + x351*(-0.00970460380625487d0*x186
     & + x211*x350 + 0.0720987654320988d0*x224) + x368*(x229*x354 + 0.98
     &7077852896471d0*x338 + 4.0d0*x357*x5 + 2.0d0*x359 + 2.0d0* x364)))
     &) - 7.5d0*x103*x168 + 4.84565491421904d0*x128 - 14.5369647426571d0
     &*x143*x31 - 2.0d0*x235 + x313*x314
      d2Ea(2) = rho_a*(-2.79576264291519d0*gamma_aa*x107*x237*x24*x320*x
     &376/x104**3 + x108*x163*x371*x376 + 1.37580302037276d0*x137*x56*( 
     &0.0453003781503037d0*x239 + x370*x374) - 0.465960440485865d0*x170 
     &*x171*x25*x372 + 0.0967061140270375d0*x23*x236*x319*x371*x45 - x56
     &*(-0.00499426203358209d0*gamma_aa*x318*x326 - 0.73048247831852d0*x
     &126*x289 + 0.105700882350709d0*x173 + x332* x380 + x370*(-x150*x18
     &7 + x150*x205 - 0.00437120219216418d0*x179* x276 - x184*x378 + x19
     &0*x383 - 1.24378109452736d0*x199 - 1.24378109452736d0*x226 - x272*
     &(-x206 + x212*x399 + x212*x400 + x401*x402 + 0.180246913580247d0*x
     &406 + 0.180246913580247d0*x409) - x280*x369 - 0.251122248871219d0*
     &x329*x382*x86 + x344*( 0.015286700226364d0*x181 + 0.005625d0*x184)
     & - 0.175340733193444d0 *x348*x381 + x351*x391 + x368*(-x228 + x229
     &*x399 + x229*x400 + x401*x410 + 2.0d0*x406 + 2.0d0*x409) - 0.00144
     &175546132004d0*x381 + x383*(-x342 + x384 - 0.099435d0) + x389*x390
     & + x396*x397))) - x238*x372 + x291*(x240 + x374*x375)
      d2Ea(3) = -rho_a*(0.668760800867552d0*x20*x23**2*x321*x325*x411 - 
     &x291*(x286*x290* x331*x380 - 0.000936424131296642d0*x326*x411 - x3
     &75*( 0.00109280054804105d0*gamma_aa*x88*x89 + x193*x338*( -0.00776
     &8359375d0*x188 + x342 + 0.0497175d0) - x222*x272*(x355* x414 + 0.1
     &80246913580247d0*x413 + 0.180246913580247d0*x417) + 2.487562189054
     &73d0*x222*x367*(x229*x414 + x413 + x417) + x273 + x275 + 0.1883416
     &86653414d0*x338*x392 + 0.0657527749475415d0*x348* x75 - x379*x396 
     &+ 1.24378109452736d0*x391*x394 - 2.48756218905473d0*x393)))
      d2Ea(4) = -x311*(rho_a*x177*(x169*x428 - x54*(5.45136177849642d0*x
     &101*x232*x31* x428*x60 - x175*x428 - x178*(-0.00699626865671642d0*
     &gamma_aa*x183 *x198*x301 + 0.00856659785039798d0*x183*x305 - 0.251
     &122248871219d0*x191*x429 + 0.00349813432835821d0*x196*x303* x347 +
     & 0.00349813432835821d0*x225*x304 - x272*x71*(x299*x434 - x402*x432
     & + 0.180246913580247d0*x433 - 0.180246913580247d0*x436 - 0.1364709
     &91025459d0*x6) + x351*x71*(-0.0720987654320988d0*x424 + x431) + x3
     &68*x71*(x292*x434 - x410*x432 + 2.0d0*x433 - 2.0d0*x436 - 1.514267
     &16069345d0*x6) + x390*x427 + x397*x428 + 0.0941708433267071d0*x429
     &*x430*x90))) + x125*x287*x423)
      d2Ea(5) = x0*x288*x291*(-x190*x437 - x266*x439*x440 - 0.0038329887
     &5050529d0*x270* x304 + x271*x444*(x212*x441 - x258*x299 + x268*x44
     &2 - x268*x443) + 0.255849428582226d0*x279*x310 + 0.009386624442775
     &24d0*x303 - 2.72568088924821d0*x310*x374*x446 + x422*x439*x80 + x4
     &30*x437 - x438*(-0.005625d0*x118 + 5.11766216345471d-5*x7) + x438*
     &( -0.0028125d0*x118 + 2.55883108172736d-5*x7) - x444*x445*(x229* x
     &441 + x241*x442 - x241*x443 - x258*x292))
      d2Ea(6) = x312*x54*(-0.0153319550020212d0*x115*x304*x422 + 0.02299
     &79325030318d0* x197*x447*x448 - x271*x451*(-x426*x435 + 0.07347681
     &4256762d0*x449 + 0.163765189230551d0*x450) - 0.206370453055914d0*x
     &282*x341*x343 - 2.72568088924821d0*x293*x421*x440 + 6.780300719522
     &91d0*x423**2* x446 + x445*x451*(-x425*x435 + 0.815290678739414d0*x
     &449 + 1.81712059283214d0*x450) - 0.0281598733283257d0*x447*x86 - 2
     &.15605617215923d-5*x335*x346*x448/tau_a**6)
      end subroutine


C*****************************************************************************
      pure subroutine D2ESRX_TPSS_GWS_ERF_case_2_3(rho_a, gamma_aa, tau_
     &a, mu, Ea, d1Ea, d2Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4), d2Ea(10)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168, x169, x170
     &, x171, x172, x173, x174, x175, x176, x177, x178, x179, x180, x181
     &, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192
     &, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203
     &, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, x214
     &, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225
     &, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236
     &, x237, x238, x239, x240, x241, x242, x243, x244, x245, x246, x247
     &, x248, x249, x250, x251, x252, x253, x254, x255, x256, x257, x258
     &, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269
     &, x270, x271, x272, x273, x274, x275, x276, x277, x278, x279, x280
     &, x281, x282, x283, x284, x285, x286, x287, x288, x289, x290, x291
     &, x292, x293, x294, x295, x296, x297, x298, x299, x300, x301, x302
     &, x303, x304, x305, x306, x307, x308, x309, x310, x311, x312, x313
     &, x314, x315, x316, x317, x318, x319, x320, x321, x322, x323, x324
     &, x325, x326, x327, x328, x329, x330, x331, x332, x333, x334, x335
     &, x336, x337, x338, x339, x340, x341, x342, x343, x344, x345, x346
     &, x347, x348, x349, x350, x351, x352, x353, x354, x355, x356, x357
     &, x358, x359, x360, x361, x362, x363, x364, x365, x366, x367, x368
     &, x369, x370, x371, x372, x373, x374, x375, x376, x377, x378, x379
     &, x380, x381, x382, x383, x384, x385, x386, x387, x388, x389, x390
     &, x391, x392, x393, x394, x395, x396, x397, x398, x399, x400, x401
     &, x402, x403, x404, x405, x406, x407, x408, x409, x410, x411, x412
     &, x413, x414, x415, x416, x417, x418, x419, x420, x421, x422, x423
     &, x424, x425, x426, x427, x428, x429, x430, x431, x432, x433, x434
     &, x435, x436, x437, x438, x439, x440, x441, x442, x443, x444, x445
     &, x446, x447, x448, x449, x450, x451, x452, x453, x454, x455, x456
     &, x457, x458, x459, x460, x461, x462, x463, x464, x465, x466, x467
     &, x468, x469, x470, x471, x472, x473, x474, x475, x476, x477, x478
     &, x479, x480
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      d2Ea(:) = 0.0d0
      x0 = rho_a**1.33333333333333d0
      x1 = 0.682784063255296d0
      x2 = 7.26848237132856d0*x1
      x3 = 1d0/x0
      x4 = 21.1705915781930d0
      x5 = 1d0/x4
      x6 = mu**4
      x7 = rho_a**0.666666666666667d0
      x8 = 4.60115111447049d0
      x9 = mu**2
      x10 = 1d0/x9
      x11 = x10*x8
      x12 = 3.30192724889463d0*x11*x7
      x13 = exp(x12)
      x14 = x5*x6*(x13 - 1.0d0)
      x15 = x14*x3
      x16 = 0.015286700226364d0*x15
      x17 = 7.0d0*x13 + 11.0d0
      x18 = 1d0/x8
      x19 = x18*x9/x7
      x20 = 0.00280419844572861d0*x17*x19
      x21 = -x16 + x20 + 0.0185185185185185d0
      x22 = rho_a**(-2.0d0)
      x23 = 3.15935190989552d0*x22
      x24 = x10*x23
      x25 = x21*x24
      x26 = 3.0d0*x13
      x27 = x26 - 2.0d0
      x28 = 2.14502939711103d0
      x29 = 1d0/x28
      x30 = rho_a**0.333333333333333d0
      x31 = 1d0/x30
      x32 = x29*x31
      x33 = mu*x32
      x34 = 1d0/mu
      x35 = x28*x34
      x36 = erf(1.8171205928321397d0*x30*x35)
      x37 = x13*x36
      x38 = 0.183440402716368d0*x15 - 0.60570686427738d0*x19*x27 - x26 +
     & 3.90167577847542d0*x33*x37
      x39 = 1d0/x38
      x40 = x39*exp(-1.4385538026587772d0*x19)
      x41 = gamma_aa*x40
      x42 = x25*x41
      x43 = -x42 + 1.0d0
      x44 = 1.804d0 - 0.804d0/x43
      x45 = 0.550321208149104d0*x32
      x46 = 1d0/rho_a
      x47 = 9.86960440108936d0
      x48 = 1d0/x47
      x49 = 0.0833333333333333d0*x48
      x50 = x46*x49
      x51 = x50*x9
      x52 = x45 - x51
      x53 = exp(-x12)
      x54 = mu*x53
      x55 = mu**3
      x56 = -0.825481812223657d0*x33 + 1.77245385090552d0*x36 + x50*x55
      x57 = x52*x54 + x56
      x58 = 0.275160604074552d0*x33
      x59 = x57*x58 - 0.375d0
      x60 = x44*x59
      x61 = 0.682784063255296d0
      x62 = 2.72568088924821d0*x61
      x63 = exp(-4.1274090611182839d0*x33)
      x64 = rho_a**(-2.66666666666667d0)
      x65 = x18*x64
      x66 = gamma_aa*x65
      x67 = 0.0206714418186455d0*x66 + 1.0d0
      x68 = 0.804d0/x67
      x69 = 0.0938662444277524d0*x66 + 1.0d0
      x70 = x69**(-2)
      x71 = 0.050475572023115d0*x66
      x72 = 1d0/gamma_aa
      x73 = tau_a*x72
      x74 = 8.0d0*rho_a*x73
      x75 = x74 - 1.0d0
      x76 = x66*x75
      x77 = 0.0567850185260044d0*x76 - 0.45d0
      x78 = 0.126188930057787d0*x76 - 1.0d0
      x79 = x75*x78
      x80 = x71*x79 + 1.0d0
      x81 = x80**(-0.5d0)
      x82 = x71 + x77*x81
      x83 = x82**2
      x84 = rho_a**(-5.33333333333333d0)*x5
      x85 = rho_a**(-2)
      x86 = tau_a**(-2)
      x87 = 0.0028125d0*x86
      x88 = 0.00286625629244325d0*x84 + x85*x87
      x89 = sqrt(x88)
      x90 = 0.00909806606836394d0*x65
      x91 = gamma_aa*x90
      x92 = x81*(0.0102353243269094d0*x76 - 0.0811111111111111d0) + x91
      x93 = x89*x92
      x94 = gamma_aa*x93
      x95 = gamma_aa**2
      x96 = x84*x95
      x97 = rho_a**(-8.0d0)
      x98 = 0.0102659822546843d0
      x99 = gamma_aa**3
      x100 = x98*x99
      x101 = x100*x97
      x102 = x85*x86
      x103 = x102*x95
      x104 = 0.015625d0*x103 + 1.0d0
      x105 = x104**(-2)
      x106 = 0.02485875d0*x103*x105 + 0.123456790123457d0
      x107 = x106*x66
      x108 = 0.000182133424673508d0*x101 + 0.0021416494625995d0*x103 + 0
     &.0941708433267071d0*x107 + 0.000135164574498753d0*x96
      x109 = x70*(x108 + 0.0896750813832074d0*x83 - 1.24378109452736d0*x
     &94) + 1.0d0
      x110 = 1d0/x109
      x111 = -0.804d0*x110
      x112 = x63*(x111 + x68)
      x113 = x42 - 1.0d0
      x114 = -x45 + x51
      x115 = -x114*x54 + x56
      x116 = x115*x58 - 0.375d0
      x117 = x116*x30
      x118 = -x74 + 1.0d0
      x119 = x118*x66
      x120 = 0.0567850185260044d0*x119 + 0.45d0
      x121 = 0.126188930057787d0*x119 + 1.0d0
      x122 = x118*x121
      x123 = x122*x71 + 1.0d0
      x124 = x123**(-0.5d0)
      x125 = -x120*x124 + x71
      x126 = x125**2
      x127 = x124*(0.0102353243269094d0*x119 + 0.0811111111111111d0)
      x128 = -x127 + x91
      x129 = x128*x89
      x130 = 1.24378109452736d0*x129
      x131 = x70*(-gamma_aa*x130 + x108 + 0.0896750813832074d0*x126) + 1
     &.0d0
      x132 = 1d0/x131
      x133 = -0.804d0*x132
      x134 = x30*x62
      x135 = rho_a**(-0.666666666666667d0)
      x136 = x1*x60
      x137 = x135*x136
      x138 = 0.318309886183791d0
      x139 = mu*x138
      x140 = x139*x46
      x141 = 3.75d0*x140
      x142 = rho_a**(-0.333333333333333d0)
      x143 = x34*x53*x8
      x144 = x142*x143
      x145 = 2.20128483259642d0*x144
      x146 = 0.183440402716368d0*x3
      x147 = x22*x49
      x148 = -x146*x29 + x147*x9
      x149 = mu*x29*x3
      x150 = x35*x53
      x151 = 1.21141372855476d0*x135*x150 - x147*x55 + x148*x54 + 0.2751
     &60604074552d0 *x149
      x152 = 0.275160604074552d0*x31
      x153 = 0.0917202013581841d0*x115*x3 - x152*(x114*x145 + x151)
      x154 = x139*x153*x44
      x155 = 7.26848237132856d0*x30
      x156 = x43**(-2)
      x157 = x16 - x20 - 0.0185185185185185d0
      x158 = rho_a**(-3.66666666666667d0)
      x159 = x158*x18
      x160 = x157*x159
      x161 = rho_a**(-3.0d0)
      x162 = x10*x157
      x163 = x161*x162
      x164 = x13*x46
      x165 = 0.0432098765432099d0*x164
      x166 = rho_a**(-1.66666666666667d0)
      x167 = x166*x18
      x168 = x167*x9
      x169 = x13*x168
      x170 = 0.0336503813487433d0*x169
      x171 = rho_a**(-2.33333333333333d0)
      x172 = x14*x171
      x173 = 0.0203822669684853d0*x172
      x174 = 0.00186946563048574d0*x168*x17
      x175 = -x165 + x170 - x173 + x174
      x176 = x10*x175
      x177 = 0.564189583547756d0
      x178 = x177*x46
      x179 = x11*x13
      x180 = 6.60385449778925d0*x179
      x181 = x168*x27
      x182 = x149*x37
      x183 = x13*x135
      x184 = x183*x35*x36
      x185 = x142*x180 + 4.0d0*x164 - 0.40380457618492d0*x169 + 0.244587
     &203621824d0* x172 - 4.72654360241471d0*x178 - 0.40380457618492d0*x
     &181 + 1.30055859282514d0*x182 - 8.58869971286677d0*x184
      x186 = x185*x39
      x187 = x162*x23
      x188 = 3.02993180261165d0*x160 - 6.31870381979104d0*x163 + x176*x2
     &3 + x186*x187
      x189 = x156*x188*x41*x59
      x190 = 5.84385982654816d0*x1
      x191 = x190*x30
      x192 = rho_a**(-3.33333333333333d0)
      x193 = 0.148394183600699d0
      x194 = x193/x67**2
      x195 = x192*x194
      x196 = -x68 + 1.804d0
      x197 = 0.90856029641607d0*x135
      x198 = x197*x61
      x199 = x109**(-2)
      x200 = 2.19144743495556d0*x30
      x201 = rho_a**(-9.0d0)
      x202 = x100*x201
      x203 = rho_a**(-6.33333333333333d0)*x5
      x204 = x203*x95
      x205 = rho_a**(-3)
      x206 = x205*x86
      x207 = x206*x95
      x208 = gamma_aa*x159
      x209 = 0.251122248871219d0*x106
      x210 = x103/x104
      x211 = 0.001553671875d0*x210
      x212 = x211 - 0.0497175d0
      x213 = x212*x99
      x214 = x105*x86
      x215 = 0.0941708433267071d0*x214
      x216 = rho_a**(-5.66666666666667d0)*x18
      x217 = x215*x216
      x218 = 0.00764335011318201d0*x203 + x205*x87
      x219 = 1d0/x89
      x220 = x219*x92
      x221 = x218*x220
      x222 = gamma_aa*x221
      x223 = 1d0/x69
      x224 = 0.0001464352734375d0*x101 + 0.00172188616792999d0*x103 + 0.
     &0757133580346725d0*x107 + 0.000108672317896998d0*x96
      x225 = x224 + 0.0720987654320988d0*x83 - x94
      x226 = x223*x225
      x227 = 0.622661654578789d0*x226
      x228 = 0.0242615095156372d0*x159
      x229 = tau_a*x64
      x230 = x158*x75
      x231 = 0.151426716069345d0*x230
      x232 = -gamma_aa*x231 + 0.454280148208035d0*x229
      x233 = x232*x81
      x234 = 0.180246913580247d0*x18
      x235 = x18*x78
      x236 = 0.20190228809246d0*x229
      x237 = 0.0673007626974867d0*x79
      x238 = 0.336503813487433d0*x230
      x239 = x5*(-gamma_aa*x238 + 1.0095114404623d0*x229)
      x240 = x64*x75
      x241 = 0.0252377860115575d0*x240
      x242 = x239*x241
      x243 = -gamma_aa*x242 + x208*x237 - x235*x236
      x244 = x80**(-1.5d0)
      x245 = x244*x77
      x246 = x243*x245
      x247 = -gamma_aa*x228 + x233*x234 + 0.180246913580247d0*x246
      x248 = x247*x89
      x249 = gamma_aa*x248
      x250 = 0.269203050789947d0*x159
      x251 = 2.0d0*x18
      x252 = -gamma_aa*x250 + x233*x251 + 2.0d0*x246
      x253 = x252*x82
      x254 = -0.00145706739738806d0*x202 - 0.000720877730660018d0*x204 -
     & 0.00428329892519899d0*x207 - x208*x209 + x208*x227 + x213*x217 + 
     &1.24378109452736d0*x222 - 1.24378109452736d0*x249 + 0.089675081383
     &2074d0*x253
      x255 = x61*x70
      x256 = x254*x255
      x257 = x63*(0.12080100840081d0*gamma_aa*x195 - x196*x198 + x198*(x
     &111 + 1.804d0 ) + x199*x200*x256)
      x258 = rho_a**(-1.66666666666667d0)
      x259 = x40/x113**2
      x260 = 18.4628097041666d0*x258*x259
      x261 = x10*x21
      x262 = x1*x116
      x263 = x261*x262
      x264 = x171*x194
      x265 = 1.09572371747778d0*x30
      x266 = 2.0d0*x120
      x267 = x123**(-1.5d0)
      x268 = 0.20190228809246d0*x167
      x269 = x121*x268
      x270 = x166*x73
      x271 = 1.0095114404623d0*x270
      x272 = x118*x64
      x273 = gamma_aa*x5
      x274 = x267*(0.0252377860115575d0*x122*x65 + x269*x73 + 0.02523778
     &60115575d0* x272*x273*(x271 + 0.126188930057787d0*x272))
      x275 = 0.10095114404623d0*x65
      x276 = 0.454280148208035d0*x270
      x277 = 0.0567850185260044d0*x272 + x276
      x278 = x124*x277
      x279 = -x251*x278 + x275
      x280 = 0.0896750813832074d0*x125
      x281 = 0.180246913580247d0*x120
      x282 = -x234*x278 + x90
      x283 = gamma_aa*x89
      x284 = 1.24378109452736d0*x283
      x285 = 0.000270329148997507d0*x84
      x286 = x106*x65
      x287 = 0.00428329892519899d0*x102
      x288 = x95*x98
      x289 = x288*x97
      x290 = -gamma_aa*x129 + 0.0720987654320988d0*x126 + x224
      x291 = x223*x65
      x292 = 0.233498120467046d0*x291
      x293 = rho_a**(-4.66666666666667d0)
      x294 = x18*x293
      x295 = x294*x95
      x296 = x212*x295
      x297 = -gamma_aa*x285 - gamma_aa*x287 + x130 + x215*x296 - 0.09417
     &08433267071d0 *x286 - 0.000546400274020523d0*x289 + x290*x292
      x298 = -x280*(x266*x274 + x279) + x284*(x274*x281 + x282) + x297
      x299 = x131**(-2)
      x300 = x255*x299
      x301 = x298*x300
      x302 = 2.0d0*x63
      x303 = -x260*x263 + x302*(0.0226501890751519d0*x264 + x265*x301)
      x304 = 0.90856029641607d0*x167
      x305 = 1d0/x123
      x306 = rho_a**(-4.33333333333333d0)
      x307 = 0.0254778337106067d0*x306
      x308 = x305*(x118*x273*x307 + x269)
      x309 = 0.0720987654320988d0*x124*x125
      x310 = 0.0818825946152754d0*x167
      x311 = x124*x283
      x312 = tau_a**(-3)
      x313 = x312*x85
      x314 = gamma_aa*x313
      x315 = x219*x314
      x316 = x312*x95
      x317 = 0.0757133580346725d0*x213
      x318 = x105*x312
      x319 = x294*x317*x318 - 0.00344377233585999d0*x316*x85
      x320 = 0.0028125d0*x128*x315 + x319
      x321 = x309*(-x266*x308 + x304) - x311*(-x281*x308 + x310) + x320
      x322 = x63*x70
      x323 = x0*x299*x322
      x324 = x1*x189
      x325 = 11.6877196530963d0*x30
      x326 = x171*x29
      x327 = mu*x326
      x328 = 0.166666666666667d0*x161*x48
      x329 = 1d0/x55
      x330 = x329*x53
      x331 = rho_a**(-1.33333333333333d0)
      x332 = x156*x41
      x333 = 6.0598636052233d0*x160
      x334 = 12.6374076395821d0*x163
      x335 = 6.31870381979104d0*x22
      x336 = x176*x335
      x337 = x191*x59
      x338 = x38**(-2)
      x339 = x338*exp(-2.8771076053175544d0*x19)
      x340 = x13*x22
      x341 = x65*x9
      x342 = x13*x341
      x343 = x14*x192
      x344 = 1d0/x6
      x345 = x35*x37
      x346 = 0.0322515344331995d0/x67**3
      x347 = 0.60570686427738d0*x258*x61
      x348 = x106*x208
      x349 = x214*x216
      x350 = 1.24532330915758d0*x208
      x351 = x61/(x131**3*x69**4)
      x352 = x200*x254*x351
      x353 = rho_a**(-7.33333333333333d0)*x5
      x354 = x353*x95
      x355 = rho_a**(-4)
      x356 = x355*x86
      x357 = gamma_aa*x293
      x358 = x18*x357
      x359 = rho_a**(-6.66666666666667d0)*x18
      x360 = tau_a**(-4)
      x361 = x105*x360
      x362 = 0.00014565673828125d0*gamma_aa**4*x355*x361
      x363 = x99*(-0.010875703125d0*x210 + x362 + 0.1491525d0)
      x364 = 1.24378109452736d0*x220
      x365 = 1.24378109452736d0*gamma_aa
      x366 = x88**(-1.5d0)
      x367 = x366*x92
      x368 = x225*x70
      x369 = x218*x219
      x370 = 0.0720987654320988d0*x18
      x371 = 1.24378109452736d0*x252
      x372 = tau_a*x158
      x373 = x357*x75
      x374 = x81*(-2.42282745710952d0*x372 + 0.555231292254265d0*x373)
      x375 = 0.360493827160494d0*x18
      x376 = x243*x244
      x377 = x232*x376
      x378 = gamma_aa*x239
      x379 = x241*x273
      x380 = x245*(-0.40380457618492d0*x229*x239 + 0.134601525394973d0*x
     &230*x378 + 1.07681220315979d0*x235*x372 - 0.246769463224118d0*x235
     &*x373 - x379*(-5.38406101579893d0*x372 + 1.23384731612059d0*x373))
     &
      x381 = 0.60570686427738d0*x78
      x382 = 0.0757133580346725d0*x240
      x383 = x243*x77
      x384 = x383*x80**(-2.5d0)
      x385 = x384*(-x18*x229*x381 + 0.20190228809246d0*x208*x79 - x378*x
     &382)
      x386 = 0.00363922642734557d0*x65
      x387 = gamma_aa*x386
      x388 = x387 + x81*(0.00409412973076377d0*x76 - 0.0324444444444444d
     &0)
      x389 = 1.24378109452736d0*x388
      x390 = -0.0011714821875d0*x202 - 0.000579585695450655d0*x204 - 0.0
     &0344377233585999d0*x207 + x222 - x249 + 0.0720987654320988d0* x253
     & + x317*x349 - 0.20190228809246d0*x348
      x391 = x200*x300
      x392 = -3.02993180261165d0*x159*x21 + 6.31870381979104d0*x161*x261
     & - x186*x25 - x24*(x165 - x170 + x173 - x174)
      x393 = x339/x113**3
      x394 = x268*x78
      x395 = x394*x73
      x396 = x65*x78
      x397 = x396*x75
      x398 = 0.0252377860115575d0*x397
      x399 = 0.126188930057787d0*x240 - x271
      x400 = x379*x399
      x401 = -x395 + x398 + x400
      x402 = x267*x401
      x403 = x266*x402 + x279
      x404 = x281*x402 + x282
      x405 = -x280*x403 + x284*x404 + x297
      x406 = gamma_aa*x84
      x407 = 0.00856659785039798d0*gamma_aa
      x408 = 0.466996240934092d0*x291
      x409 = -x102*x407 - 0.179350162766415d0*x125*x403 + 2.487562189054
     &73d0*x129 + 0.188341686653414d0*x214*x296 + 2.48756218905473d0*x28
     &3*x404 - 0.188341686653414d0*x286 - 0.00109280054804105d0*x289 + x
     &290*x408 - 0.000540658297995013d0*x406
      x410 = gamma_aa*x203
      x411 = -x211 + 0.0497175d0
      x412 = x217*x95
      x413 = 0.00932203125d0*x210
      x414 = 0.0567850185260044d0*x240 - x276
      x415 = x414*x81
      x416 = x395 - x398 - x400
      x417 = x245*x416
      x418 = x234*x415 + 0.180246913580247d0*x417 + x90
      x419 = x365*x369
      x420 = x370*x415 + x386 + 0.0720987654320988d0*x417
      x421 = x214*x411
      x422 = x418*x89
      x423 = x251*x415 + x275 + 2.0d0*x417
      x424 = 0.0720987654320988d0*x82
      x425 = 0.00344377233585999d0*gamma_aa*x102 - gamma_aa*x422 + 0.075
     &7133580346725d0*x286 + 0.0004393058203125d0*x289 + 0.0757133580346
     &725d0*x295*x421 + 0.000217344635793995d0*x406 + x423*x424 - x93
      x426 = 0.622661654578789d0*x208*x223
      x427 = x229*x72
      x428 = x81*(-x231 + 1.21141372855476d0*x427)
      x429 = x376*x414
      x430 = x244*x416
      x431 = x232*x234
      x432 = x167*x381
      x433 = x273*x399
      x434 = -x382*x433 - 0.0757133580346725d0*x397 + x432*x73
      x435 = x384*x434
      x436 = 0.20190228809246d0*x166
      x437 = x239*x436
      x438 = x245*(x159*x237 + 0.0673007626974867d0*x230*x433 - 0.538406
     &101579893d0* x235*x427 - x236*x399*x5 - x242 - x379*(-x238 + 2.692
     &03050789947d0*x427) + x437*x73)
      x439 = x232*x251
      x440 = x5*x77
      x441 = x399*x440*(-0.050475572023115d0*x240 + 0.40380457618492d0*x
     &270)
      x442 = x414*x416
      x443 = 1d0/x80
      x444 = x443*x77
      x445 = x416*x434*x444
      x446 = x307*x75
      x447 = x273*x446 + x394
      x448 = x305*x447
      x449 = x266*x448 + x304
      x450 = x281*x448 + x310
      x451 = x309*x449 - x311*x450 + x320
      x452 = x444*x447
      x453 = 2.0d0*x452
      x454 = 0.180246913580247d0*x452
      x455 = x81*(x310 - x454)
      x456 = 0.0028125d0*x220*x314 - x283*x455 + x319 + x424*x81*(x304 -
     & x453)
      x457 = x216*x318
      x458 = x362 - x413 + 0.099435d0
      x459 = 0.0327530378461102d0*x167
      x460 = x443*x447
      x461 = x306*x5
      x462 = x444*(-0.203822669684853d0*tau_a*x461 + 0.336503813487433d0
     &*x396 + 0.110403946079296d0*x406*x75 - x437)
      x463 = x243*x443
      x464 = 0.0764335011318201d0*gamma_aa*x461*x75 + x432
      x465 = x383*x464/x80**2
      x466 = 0.103185226527957d0*x105*x294*x316
      x467 = 1.3628404446241d0*x219*x313
      x468 = 1.3628404446241d0*x124
      x469 = 0.0720987654320988d0*x120*x448 + x459
      x470 = x277*x447
      x471 = x5*(-0.203822669684853d0*x192*x73 + x399*x436 + x446)
      x472 = x305*x401*x464
      x473 = 1.3628404446241d0*x267
      x474 = -x124*(0.00409412973076377d0*x119 + 0.0324444444444444d0) +
     & x387
      x475 = x132*x70
      x476 = x360*x85
      x477 = gamma_aa*x128
      x478 = x192*x440
      x479 = x167*x447
      x480 = 2.72568088924821d0*x244
      Ea = -x0*(x112*x62 - x2*x60)
      d1Ea(1) = -rho_a*(x112*x141 - 2.42282745710952d0*x137 + x154*x155 
     &- x189*x191 + x257) + x117*x2*(1.804d0 + 0.804d0/x113) - x134*x63*
     &(x133 + x68)
      d1Ea(2) = rho_a*x303
      d1Ea(3) = -x321*x323*x62
      d2Ea(1) = rho_a*(5.0d0*rho_a**(-2.0d0)*x112*x139 - 5.1592613263978
     &5d0*x112*x171* x193*x9 - 4.84565491421904d0*x135*x154 + 3.89590655
     &103211d0*x135* x324 - 1.61521830473968d0*x136*x258 - x139*x153*x18
     &8*x325*x332 + x139*x155*x44*(-x146*(-x145*x52 + x151) + x152*( 4.8
     &4565491421904d0*x135*x330*x4*x52 + 0.733761610865473d0*x143* x331*
     &x52 - 4.40256966519284d0*x144*x148 - 0.80760915236984d0*x150 *x258
     & - 0.366880805432736d0*x327 + x328*x55 - 2.66666666666667d0* x330*
     &x46*x47 + x54*(0.244587203621824d0*x326 - x328*x9)) + 0.1222936018
     &10912d0*x171*x57) - 2.75160604074552d0*x149*x257 - x188*x337*x339*
     &x95*(x162*x186*x335 + x333 - x334 + x336)/x43**3 + x332*x337*(18.9
     &561114593731d0*rho_a**(-4.0d0)*x162 - 17.1696135481327d0*x157*x294
     & + 2.90581327762917d0*x157*x84*x9 + 6.0598636052233d0*x159*x175 - 
     &12.6374076395821d0*x161*x176 + x185 *x187*x338*(13.2077089955785d0
     &*x142*x179 + 8.0d0*x164 - 0.80760915236984d0*x169 + 0.489174407243
     &648d0*x172 - 9.45308720482942d0*x178 - 0.80760915236984d0*x181 + 2
     &.60111718565028d0*x182 - 17.1773994257335d0*x184) + x186*x333 - x1
     &86*x334 + x186*x336 + x187*x39*(-27.0091844287146d0*x10*x331 - 18.
     &9061744096588d0*x164*x329*x36*x47 + 2.86289990428892d0*x166* x345 
     &+ 6.30205813655294d0*x177*x22 + x180*x331 + 14.5369647426571d0*x18
     &3*x344*x4 + 5.72579980857785d0*x258*x345 + 0.673007626974866d0*x27
     &*x341 - 1.73407812376686d0*x327*x37 - 7.55555555555556d0*x340 + 1.
     &21141372855476d0*x342 - 0.57070347511759d0*x343) + x24*(-0.0031157
     &7605080957d0*x17*x341 - 0.0951172458529316d0*x179*x331 + 0.1460905
     &34979424d0*x340 - 0.10095114404623d0*x342 + 0.0475586229264658d0*x
     &343)) + x63*( 0.36240302520243d0*gamma_aa*x194*x306 - 0.0133180320
     &895522d0* rho_a**(-7.0d0)*x346*x95 - 1.46096495663704d0*x135*x256*
     &x299 - x196*x347 + x347*(x133 + 1.804d0) + x352*(-0.00291413479477
     &612d0* x202 - 0.00144175546132004d0*x204 - 0.00856659785039798d0*x
     &207 + 0.188341686653414d0*x213*x349 + 2.48756218905473d0*x222 + x2
     &26* x350 - 2.48756218905473d0*x249 + 0.179350162766415d0*x253 - 0.
     &502244497742438d0*x348) - x391*(2.48756218905473d0*gamma_aa* x247*
     &x369 - gamma_aa*x364*(0.0484078840501527d0*x353 + 0.0084375d0*x356
     &) + 0.0131136065764925d0*rho_a**(-10.0d0)*x100 + 0.920781579194469
     &d0*x106*x358 - 0.502244497742438d0*x213*x214* x359 + x215*x359*x36
     &3 + x218**2*x365*x367 + x223*x350*x390 - 2.28309273345556d0*x226*x
     &358 - x284*(x234*x374 + 0.0889588682240029d0*x358 + x375*x377 + 0.
     &180246913580247d0*x380 + 0.180246913580247d0*x385) + 0.46757528851
     &585d0*x354*x368 + 0.00456555896084678d0*x354 + 0.012849896775597d0
     &*x356*x95 + x371* (-0.00970460380625487d0*x208 + x233*x370 + 0.072
     &0987654320988d0* x246) + x389*(4.0d0*x18*x377 + x251*x374 + 0.9870
     &77852896471d0* x358 + 2.0d0*x380 + 2.0d0*x385)))) - 7.5d0*x112*x14
     &0 + 4.84565491421904d0*x137 - 14.5369647426571d0*x154*x30 - 2.0d0*
     & x257 + x324*x325
      d2Ea(2) = rho_a*(-36.9256194083333d0*gamma_aa*x258*x263*x392*x393 
     &- 6.15426990138888d0*rho_a**(-2.66666666666667d0)*x259*x263 + x117
     &* x190*x259*x392 + x138*x153*x21*x260*x34 + 1.37580302037276d0*x14
     &9 *x63*(x200*x301 + 0.0453003781503037d0*x264) - x63*( -0.00499426
     &203358209d0*gamma_aa*rho_a**(-6.0d0)*x346 - 0.73048247831852d0*x13
     &5*x300*x405 + 0.105700882350709d0*x195 + x352*x409 + x391*(-x159*x
     &209 + x159*x227 - 0.00437120219216418d0* x201*x288 - x206*x407 + x
     &212*x412 - 1.24378109452736d0*x221 - 1.24378109452736d0*x248 - x28
     &4*(-x228 + x234*x428 + x234*x429 + x430*x431 + 0.180246913580247d0
     &*x435 + 0.180246913580247d0*x438) - x292*x390 - 0.251122248871219d
     &0*x349*x411*x95 + x364*( 0.015286700226364d0*x203 + 0.005625d0*x20
     &6) - 0.175340733193444d0 *x368*x410 + x371*x420 + x389*(-x250 + x2
     &51*x428 + x251*x429 + x430*x439 + 2.0d0*x435 + 2.0d0*x438) - 0.001
     &44175546132004d0*x410 + x412*(-x362 + x413 - 0.099435d0) + x418*x4
     &19 + x425*x426))) + x303
      d2Ea(3) = rho_a*(116.661026201793d0*rho_a**(-3.66666666666667d0)*x
     &21**2*x262*x344* x393 - x302*(0.000936424131296642d0*rho_a**(-5.0d
     &0)*x346 + x265* x300*(0.00109280054804105d0*gamma_aa*x97*x98 + x21
     &5*x358*( -0.007768359375d0*x210 + x362 + 0.0497175d0) - x244*x284*
     &(x375* x442 + 0.180246913580247d0*x441 + 0.180246913580247d0*x445)
     & + 2.48756218905473d0*x244*x388*(x251*x442 + x441 + x445) + x285 +
     & x287 + 0.188341686653414d0*x358*x421 + 0.0657527749475415d0*x368*
     & x84 - x408*x425 + 1.24378109452736d0*x420*x423 - 2.48756218905473
     &d0*x422) - x265*x351*x405*x409))
      d2Ea(4) = -x322*(rho_a*x199*(x141*x456 - x61*(5.45136177849642d0*x
     &110*x254*x30* x456*x70 - x197*x456 - x200*(-0.00699626865671642d0*
     &gamma_aa*x205 *x220*x312 + 0.00856659785039798d0*x205*x316 - 0.251
     &122248871219d0*x213*x457 + 0.00349813432835821d0*x218*x314* x367 +
     & 0.00349813432835821d0*x247*x315 - x284*x81*(x310*x463 - x431*x460
     & + 0.180246913580247d0*x462 - 0.180246913580247d0*x465 - 0.1364709
     &91025459d0*x65) + x371*x81*(-0.0720987654320988d0*x452 + x459) + x
     &389*x81*(x304*x463 - x439*x460 + 2.0d0*x462 - 2.0d0*x465 - 1.51426
     &716069345d0*x65) + x419*x455 + x426*x456 + 0.0941708433267071d0*x4
     &57*x458*x99))) + x134*x299*x451)
      d2Ea(5) = x0*x300*x302*(-x212*x466 + x283*x473*(x234*x470 + x281*x
     &471 - x281*x472 - x310*x401) + 0.255849428582226d0*x291*x321 - 2.7
     &2568088924821d0 *x298*x321*x475 + 0.00938662444277524d0*x314 - 0.0
     &0383298875050529d0*x315*x404 - x403*x468*x469 + x450*x468*x89 + x4
     &58*x466 - x467*(-0.005625d0*x127 + 5.11766216345471d-5*x66) + x467
     &*(-0.0028125d0*x127 + 2.55883108172736d-5*x66) - x473*x474*( x251*
     &x470 + x266*x471 - x266*x472 - x304*x401))
      d2Ea(6) = x323*x61*(-0.0153319550020212d0*x124*x315*x450 + 0.02299
     &79325030318d0* x219*x476*x477 - x283*x480*(-x454*x464 + 0.07347681
     &4256762d0*x478 + 0.163765189230551d0*x479) - 0.206370453055914d0*x
     &294*x361*x363 - 2.72568088924821d0*x305*x449*x469 + 6.780300719522
     &91d0*x451**2* x475 + x474*x480*(-x453*x464 + 0.815290678739414d0*x
     &478 + 1.81712059283214d0*x479) - 0.0281598733283257d0*x476*x95 - 2
     &.15605617215923d-5*x355*x366*x477/tau_a**6)
      end subroutine


C*****************************************************************************
      pure subroutine D2ESRX_TPSS_GWS_ERF_case_3(rho_a, gamma_aa, tau_a,
     & mu, Ea, d1Ea, d2Ea)
C*****************************************************************************
C   Implemented by E.R. Kjellgren.
C
C   Subroutine generated using Sympy 1.3
C   Generated: March 21, 2019
C*****************************************************************************
      implicit none
      real*8, intent(in) :: rho_a, gamma_aa, tau_a, mu
      real*8, intent(out) :: Ea, d1Ea(4), d2Ea(10)
      real*8 :: x0, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12, x
     &13, x14, x15, x16, x17, x18, x19, x20, x21, x22, x23, x24, x25, x2
     &6, x27, x28, x29, x30, x31, x32, x33, x34, x35, x36, x37, x38, x39
     &, x40, x41, x42, x43, x44, x45, x46, x47, x48, x49, x50, x51, x52,
     & x53, x54, x55, x56, x57, x58, x59, x60, x61, x62, x63, x64, x65, 
     &x66, x67, x68, x69, x70, x71, x72, x73, x74, x75, x76, x77, x78, x
     &79, x80, x81, x82, x83, x84, x85, x86, x87, x88, x89, x90, x91, x9
     &2, x93, x94, x95, x96, x97, x98, x99, x100, x101, x102, x103, x104
     &, x105, x106, x107, x108, x109, x110, x111, x112, x113, x114, x115
     &, x116, x117, x118, x119, x120, x121, x122, x123, x124, x125, x126
     &, x127, x128, x129, x130, x131, x132, x133, x134, x135, x136, x137
     &, x138, x139, x140, x141, x142, x143, x144, x145, x146, x147, x148
     &, x149, x150, x151, x152, x153, x154, x155, x156, x157, x158, x159
     &, x160, x161, x162, x163, x164, x165, x166, x167, x168, x169, x170
     &, x171, x172, x173, x174, x175, x176, x177, x178, x179, x180, x181
     &, x182, x183, x184, x185, x186, x187, x188, x189, x190, x191, x192
     &, x193, x194, x195, x196, x197, x198, x199, x200, x201, x202, x203
     &, x204, x205, x206, x207, x208, x209, x210, x211, x212, x213, x214
     &, x215, x216, x217, x218, x219, x220, x221, x222, x223, x224, x225
     &, x226, x227, x228, x229, x230, x231, x232, x233, x234, x235, x236
     &, x237, x238, x239, x240, x241, x242, x243, x244, x245, x246, x247
     &, x248, x249, x250, x251, x252, x253, x254, x255, x256, x257, x258
     &, x259, x260, x261, x262, x263, x264, x265, x266, x267, x268, x269
     &, x270, x271, x272, x273, x274, x275, x276, x277, x278, x279, x280
     &, x281, x282, x283, x284, x285, x286, x287, x288, x289, x290, x291
     &, x292, x293, x294, x295, x296, x297, x298, x299, x300, x301, x302
     &, x303, x304, x305, x306, x307, x308, x309, x310, x311, x312, x313
     &, x314, x315, x316, x317, x318, x319, x320, x321, x322, x323, x324
     &, x325, x326, x327, x328, x329, x330, x331, x332, x333, x334, x335
     &, x336, x337, x338, x339, x340, x341, x342, x343, x344, x345, x346
     &, x347, x348, x349, x350, x351, x352, x353, x354, x355, x356, x357
     &, x358, x359, x360, x361, x362, x363, x364, x365, x366, x367, x368
     &, x369, x370, x371, x372, x373, x374, x375, x376, x377, x378, x379
     &, x380, x381, x382, x383, x384, x385, x386, x387, x388, x389, x390
     &, x391, x392, x393, x394, x395, x396
      Ea = 0.0d0
      d1Ea(:) = 0.0d0
      d2Ea(:) = 0.0d0
      x0 = rho_a**1.0d0
      x1 = 4.60115111447049d0
      x2 = 1d0/x1
      x3 = mu**2
      x4 = rho_a**0.666666666666667d0
      x5 = x2*x3/x4
      x6 = exp(-1.4385538026587772d0*x5)
      x7 = rho_a**(-2.66666666666667d0)
      x8 = x2*x7
      x9 = gamma_aa*x8
      x10 = 1d0/x3
      x11 = 0.183440402716368d0*x1*x4
      x12 = rho_a**1.33333333333333d0
      x13 = 21.1705915781930d0
      x14 = x10*x13
      x15 = 0.010095114404623d0*x12*x14
      x16 = 97.4090910340024d0
      x17 = mu**(-4)
      x18 = x16*x17
      x19 = 0.147857142857143d0*rho_a**2.0d0*x18
      x20 = -x11 + x15 + x19
      x21 = x10*x20
      x22 = 0.239205142311446d0*x21*x6*x9
      x23 = -x22 + 1.0d0
      x24 = 3.14159265358979d0
      x25 = x10*x24
      x26 = x25*(1.804d0 - 0.804d0/x23)
      x27 = 1.0d0*x26
      x28 = rho_a**0.333333333333333d0
      x29 = 0.466194077035412d0*mu
      x30 = exp(-4.1274090611182839d0*x29/x28)
      x31 = 0.0206714418186455d0*x9 + 1.0d0
      x32 = 0.804d0/x31
      x33 = 0.0938662444277524d0*x9 + 1.0d0
      x34 = x33**(-2)
      x35 = 0.050475572023115d0*x9
      x36 = 1d0/gamma_aa
      x37 = tau_a*x36
      x38 = 8.0d0*rho_a*x37
      x39 = x38 - 1.0d0
      x40 = x39*x9
      x41 = 0.0567850185260044d0*x40 - 0.45d0
      x42 = 0.126188930057787d0*x40 - 1.0d0
      x43 = x39*x42
      x44 = x35*x43 + 1.0d0
      x45 = x44**(-0.5d0)
      x46 = x35 + x41*x45
      x47 = x46**2
      x48 = 1d0/x13
      x49 = rho_a**(-5.33333333333333d0)*x48
      x50 = rho_a**(-2)
      x51 = tau_a**(-2)
      x52 = 0.0028125d0*x51
      x53 = 0.00286625629244325d0*x49 + x50*x52
      x54 = sqrt(x53)
      x55 = 0.00909806606836394d0*x8
      x56 = gamma_aa*x55
      x57 = x45*(0.0102353243269094d0*x40 - 0.0811111111111111d0) + x56
      x58 = x54*x57
      x59 = gamma_aa*x58
      x60 = gamma_aa**2
      x61 = x49*x60
      x62 = rho_a**(-8.0d0)
      x63 = 1d0/x16
      x64 = gamma_aa**3
      x65 = x63*x64
      x66 = x62*x65
      x67 = x50*x51
      x68 = x60*x67
      x69 = 0.015625d0*x68 + 1.0d0
      x70 = x69**(-2)
      x71 = 0.02485875d0*x68*x70 + 0.123456790123457d0
      x72 = x71*x9
      x73 = 0.000135164574498753d0*x61 + 0.000182133424673508d0*x66 + 0.
     &0021416494625995d0*x68 + 0.0941708433267071d0*x72
      x74 = x34*(0.0896750813832074d0*x47 - 1.24378109452736d0*x59 + x73
     &) + 1.0d0
      x75 = 1d0/x74
      x76 = -0.804d0*x75
      x77 = x30*(x32 + x76)
      x78 = 0.682784063255296d0
      x79 = x28*x78
      x80 = 2.72568088924821d0*x79
      x81 = x0*x27 + x77*x80
      x82 = x11 - x15 - x19
      x83 = rho_a**(-4.33333333333333d0)
      x84 = x48*x83
      x85 = x82*x84
      x86 = rho_a**(-3.66666666666667d0)
      x87 = x2*x86
      x88 = x10*x82
      x89 = x87*x88
      x90 = 0.122293601810912d0*rho_a**(-0.333333333333333d0)*x1
      x91 = 0.0134601525394973d0*rho_a**0.333333333333333d0*x14
      x92 = 0.295714285714286d0*x18
      x93 = x0*x92
      x94 = x90 - x91 - x93
      x95 = x10*x94
      x96 = 0.239205142311446d0*x8
      x97 = x25*(0.229406311391776d0*x85 - 0.637880379497189d0*x89 + x95
     &*x96)
      x98 = gamma_aa*x6/x23**2
      x99 = x97*x98
      x100 = 0.804d0*x0
      x101 = mu/x24
      x102 = x101/x0
      x103 = 3.75d0*x102
      x104 = rho_a**(-3.33333333333333d0)
      x105 = 0.148394183600699d0
      x106 = x105/x31**2
      x107 = x104*x106
      x108 = -x32 + 1.804d0
      x109 = rho_a**(-0.666666666666667d0)
      x110 = 0.90856029641607d0*x109
      x111 = x110*x78
      x112 = x74**(-2)
      x113 = 2.19144743495556d0*x28
      x114 = rho_a**(-9.0d0)
      x115 = x114*x65
      x116 = rho_a**(-6.33333333333333d0)*x48
      x117 = x116*x60
      x118 = rho_a**(-3)
      x119 = x118*x51
      x120 = x119*x60
      x121 = gamma_aa*x87
      x122 = 0.251122248871219d0*x71
      x123 = x68/x69
      x124 = 0.001553671875d0*x123
      x125 = x124 - 0.0497175d0
      x126 = x125*x64
      x127 = x51*x70
      x128 = 0.0941708433267071d0*x127
      x129 = rho_a**(-5.66666666666667d0)*x2
      x130 = x128*x129
      x131 = 0.00764335011318201d0*x116 + x118*x52
      x132 = 1d0/x54
      x133 = x132*x57
      x134 = x131*x133
      x135 = gamma_aa*x134
      x136 = 1d0/x33
      x137 = 0.000108672317896998d0*x61 + 0.0001464352734375d0*x66 + 0.0
     &0172188616792999d0*x68 + 0.0757133580346725d0*x72
      x138 = x137 + 0.0720987654320988d0*x47 - x59
      x139 = x136*x138
      x140 = 0.622661654578789d0*x139
      x141 = 0.0242615095156372d0*x87
      x142 = tau_a*x7
      x143 = x39*x86
      x144 = 0.151426716069345d0*x143
      x145 = -gamma_aa*x144 + 0.454280148208035d0*x142
      x146 = x145*x45
      x147 = 0.180246913580247d0*x2
      x148 = x2*x42
      x149 = 0.20190228809246d0*x142
      x150 = 0.0673007626974867d0*x43
      x151 = 0.336503813487433d0*x143
      x152 = x48*(-gamma_aa*x151 + 1.0095114404623d0*x142)
      x153 = x39*x7
      x154 = 0.0252377860115575d0*x153
      x155 = x152*x154
      x156 = -gamma_aa*x155 + x121*x150 - x148*x149
      x157 = x44**(-1.5d0)
      x158 = x157*x41
      x159 = x156*x158
      x160 = -gamma_aa*x141 + x146*x147 + 0.180246913580247d0*x159
      x161 = x160*x54
      x162 = gamma_aa*x161
      x163 = 0.269203050789947d0*x87
      x164 = 2.0d0*x2
      x165 = -gamma_aa*x163 + x146*x164 + 2.0d0*x159
      x166 = x165*x46
      x167 = -0.00145706739738806d0*x115 - 0.000720877730660018d0*x117 -
     & 0.00428329892519899d0*x120 - x121*x122 + x121*x140 + x126*x130 + 
     &1.24378109452736d0*x135 - 1.24378109452736d0*x162 + 0.089675081383
     &2074d0*x166
      x168 = x34*x78
      x169 = x167*x168
      x170 = x30*(0.12080100840081d0*gamma_aa*x107 - x108*x111 + x111*(x
     &76 + 1.804d0 ) + x112*x113*x169)
      x171 = rho_a**(-1.66666666666667d0)
      x172 = 0.682784063255296d0
      x173 = x17*x171*x172*x20
      x174 = x22 - 1.0d0
      x175 = x6/x174**2
      x176 = 0.192320934418403d0*x175
      x177 = rho_a**(-2.33333333333333d0)
      x178 = x106*x177
      x179 = -x38 + 1.0d0
      x180 = x179*x9
      x181 = 0.0567850185260044d0*x180 + 0.45d0
      x182 = 0.126188930057787d0*x180 + 1.0d0
      x183 = x179*x182
      x184 = x183*x35 + 1.0d0
      x185 = x184**(-0.5d0)
      x186 = -x181*x185 + x35
      x187 = x186**2
      x188 = x185*(0.0102353243269094d0*x180 + 0.0811111111111111d0)
      x189 = -x188 + x56
      x190 = x189*x54
      x191 = 1.24378109452736d0*x190
      x192 = x34*(-gamma_aa*x191 + 0.0896750813832074d0*x187 + x73) + 1.
     &0d0
      x193 = x192**(-2)
      x194 = 2.0d0*x181
      x195 = x184**(-1.5d0)
      x196 = x171*x2
      x197 = 0.20190228809246d0*x196
      x198 = x182*x197
      x199 = x171*x37
      x200 = 1.0095114404623d0*x199
      x201 = x179*x7
      x202 = gamma_aa*x48
      x203 = x195*(0.0252377860115575d0*x183*x8 + x198*x37 + 0.025237786
     &0115575d0* x201*x202*(x200 + 0.126188930057787d0*x201))
      x204 = 0.10095114404623d0*x8
      x205 = 0.454280148208035d0*x199
      x206 = 0.0567850185260044d0*x201 + x205
      x207 = x185*x206
      x208 = -x164*x207 + x204
      x209 = 0.0896750813832074d0*x186
      x210 = 0.180246913580247d0*x181
      x211 = -x147*x207 + x55
      x212 = gamma_aa*x54
      x213 = 1.24378109452736d0*x212
      x214 = 0.000270329148997507d0*x49
      x215 = x71*x8
      x216 = 0.00428329892519899d0*x67
      x217 = x60*x63
      x218 = x217*x62
      x219 = -gamma_aa*x190 + x137 + 0.0720987654320988d0*x187
      x220 = x136*x8
      x221 = 0.233498120467046d0*x220
      x222 = rho_a**(-4.66666666666667d0)
      x223 = x2*x222
      x224 = x223*x60
      x225 = x125*x224
      x226 = -gamma_aa*x214 - gamma_aa*x216 + x128*x225 + x191 - 0.09417
     &08433267071d0 *x215 - 0.000546400274020523d0*x218 + x219*x221
      x227 = -x209*(x194*x203 + x208) + x213*(x203*x210 + x211) + x226
      x228 = x193*x227
      x229 = 1.09572371747778d0*x79
      x230 = x229*x34
      x231 = 2.0d0*x30
      x232 = x173*x176 + x231*(0.0226501890751519d0*x178 + x228*x230)
      x233 = 0.90856029641607d0*x196
      x234 = 1d0/x184
      x235 = 0.0254778337106067d0*x83
      x236 = x234*(x179*x202*x235 + x198)
      x237 = 0.0720987654320988d0*x185*x186
      x238 = 0.0818825946152754d0*x196
      x239 = x185*x212
      x240 = tau_a**(-3)
      x241 = x240*x50
      x242 = gamma_aa*x241
      x243 = x132*x242
      x244 = x240*x60
      x245 = 0.0757133580346725d0*x126
      x246 = x240*x70
      x247 = x223*x245*x246 - 0.00344377233585999d0*x244*x50
      x248 = 0.0028125d0*x189*x243 + x247
      x249 = x237*(-x194*x236 + x233) - x239*(-x210*x236 + x238) + x248
      x250 = 2.72568088924821d0*x249
      x251 = x30*x34
      x252 = x12*x193
      x253 = x251*x252*x78
      x254 = 1.608d0*x99
      x255 = x10*x96
      x256 = rho_a**(-6.0d0)
      x257 = x100*x25
      x258 = exp(-2.8771076053175544d0*x5)
      x259 = x29/x12
      x260 = 0.0322515344331995d0/x31**3
      x261 = 0.60570686427738d0*rho_a**(-1.66666666666667d0)*x78
      x262 = 1d0/x192
      x263 = x109*x193
      x264 = x121*x71
      x265 = x127*x129
      x266 = 1.24532330915758d0*x121
      x267 = 1/(x192**3*x33**4)
      x268 = x113*x167*x267*x78
      x269 = rho_a**(-7.33333333333333d0)*x48
      x270 = x269*x60
      x271 = rho_a**(-4)
      x272 = x271*x51
      x273 = gamma_aa*x222
      x274 = x2*x273
      x275 = rho_a**(-6.66666666666667d0)*x2
      x276 = tau_a**(-4)
      x277 = x276*x70
      x278 = 0.00014565673828125d0*gamma_aa**4*x271*x277
      x279 = x64*(-0.010875703125d0*x123 + x278 + 0.1491525d0)
      x280 = 1.24378109452736d0*x133
      x281 = 1.24378109452736d0*gamma_aa
      x282 = x53**(-1.5d0)
      x283 = x282*x57
      x284 = x138*x34
      x285 = x131*x132
      x286 = 0.0720987654320988d0*x2
      x287 = 1.24378109452736d0*x165
      x288 = tau_a*x86
      x289 = x273*x39
      x290 = x45*(-2.42282745710952d0*x288 + 0.555231292254265d0*x289)
      x291 = 0.360493827160494d0*x2
      x292 = x156*x157
      x293 = x145*x292
      x294 = gamma_aa*x152
      x295 = x154*x202
      x296 = x158*(-0.40380457618492d0*x142*x152 + 0.134601525394973d0*x
     &143*x294 + 1.07681220315979d0*x148*x288 - 0.246769463224118d0*x148
     &*x289 - x295*(-5.38406101579893d0*x288 + 1.23384731612059d0*x289))
     &
      x297 = 0.60570686427738d0*x42
      x298 = 0.0757133580346725d0*x153
      x299 = x156*x41
      x300 = x299*x44**(-2.5d0)
      x301 = x300*(0.20190228809246d0*x121*x43 - x142*x2*x297 - x294*x29
     &8)
      x302 = 0.00363922642734557d0*x8
      x303 = gamma_aa*x302
      x304 = x303 + x45*(0.00409412973076377d0*x40 - 0.0324444444444444d
     &0)
      x305 = 1.24378109452736d0*x304
      x306 = -0.0011714821875d0*x115 - 0.000579585695450655d0*x117 - 0.0
     &0344377233585999d0*x120 + x135 - x162 + 0.0720987654320988d0* x166
     & + x245*x265 - 0.20190228809246d0*x264
      x307 = x113*x168
      x308 = x193*x307
      x309 = -0.229406311391776d0*x20*x84 + 0.637880379497189d0*x21*x87 
     &- x255*(-x90 + x91 + x93)
      x310 = x258/x174**3
      x311 = x197*x42
      x312 = x311*x37
      x313 = x42*x8
      x314 = x313*x39
      x315 = 0.0252377860115575d0*x314
      x316 = 0.126188930057787d0*x153 - x200
      x317 = x295*x316
      x318 = -x312 + x315 + x317
      x319 = x195*x318
      x320 = x194*x319 + x208
      x321 = x210*x319 + x211
      x322 = -x209*x320 + x213*x321 + x226
      x323 = gamma_aa*x49
      x324 = 0.00856659785039798d0*gamma_aa
      x325 = 0.466996240934092d0*x220
      x326 = 0.188341686653414d0*x127*x225 - 0.179350162766415d0*x186*x3
     &20 + 2.48756218905473d0*x190 + 2.48756218905473d0*x212*x321 - 0.18
     &8341686653414d0*x215 - 0.00109280054804105d0*x218 + x219*x325 - 0.
     &000540658297995013d0*x323 - x324*x67
      x327 = gamma_aa*x116
      x328 = -x124 + 0.0497175d0
      x329 = x130*x60
      x330 = 0.00932203125d0*x123
      x331 = 0.0567850185260044d0*x153 - x205
      x332 = x331*x45
      x333 = x312 - x315 - x317
      x334 = x158*x333
      x335 = x147*x332 + 0.180246913580247d0*x334 + x55
      x336 = x281*x285
      x337 = x286*x332 + x302 + 0.0720987654320988d0*x334
      x338 = x127*x328
      x339 = x335*x54
      x340 = x164*x332 + x204 + 2.0d0*x334
      x341 = 0.0720987654320988d0*x46
      x342 = -gamma_aa*x339 + 0.00344377233585999d0*gamma_aa*x67 + 0.075
     &7133580346725d0*x215 + 0.0004393058203125d0*x218 + 0.0757133580346
     &725d0*x224*x338 + 0.000217344635793995d0*x323 + x340*x341 - x58
      x343 = 0.622661654578789d0*x121*x136
      x344 = x142*x36
      x345 = x45*(-x144 + 1.21141372855476d0*x344)
      x346 = x292*x331
      x347 = x157*x333
      x348 = x145*x147
      x349 = x196*x297
      x350 = x202*x316
      x351 = -x298*x350 - 0.0757133580346725d0*x314 + x349*x37
      x352 = x300*x351
      x353 = 0.20190228809246d0*x171
      x354 = x152*x353
      x355 = x158*(0.0673007626974867d0*x143*x350 - 0.538406101579893d0*
     &x148*x344 - x149*x316*x48 + x150*x87 - x155 - x295*(-x151 + 2.6920
     &3050789947d0*x344) + x354*x37)
      x356 = x145*x164
      x357 = x41*x48
      x358 = x316*x357*(-0.050475572023115d0*x153 + 0.40380457618492d0*x
     &199)
      x359 = x331*x333
      x360 = 1d0/x44
      x361 = x360*x41
      x362 = x333*x351*x361
      x363 = x235*x39
      x364 = x202*x363 + x311
      x365 = x234*x364
      x366 = x194*x365 + x233
      x367 = x210*x365 + x238
      x368 = x237*x366 - x239*x367 + x248
      x369 = x361*x364
      x370 = 2.0d0*x369
      x371 = 0.180246913580247d0*x369
      x372 = x45*(x238 - x371)
      x373 = 0.0028125d0*x133*x242 - x212*x372 + x247 + x341*x45*(x233 -
     & x370)
      x374 = x129*x246
      x375 = x278 - x330 + 0.099435d0
      x376 = 0.0327530378461102d0*x196
      x377 = x360*x364
      x378 = x361*(-0.203822669684853d0*tau_a*x84 + 0.336503813487433d0*
     &x313 + 0.110403946079296d0*x323*x39 - x354)
      x379 = x156*x360
      x380 = 0.0764335011318201d0*gamma_aa*x39*x84 + x349
      x381 = x299*x380/x44**2
      x382 = 0.103185226527957d0*x223*x244*x70
      x383 = 1.3628404446241d0*x132*x241
      x384 = 1.3628404446241d0*x185
      x385 = 0.0720987654320988d0*x181*x365 + x376
      x386 = x206*x364
      x387 = x48*(-0.203822669684853d0*x104*x37 + x316*x353 + x363)
      x388 = x234*x318*x380
      x389 = 1.3628404446241d0*x195
      x390 = -x185*(0.00409412973076377d0*x180 + 0.0324444444444444d0) +
     & x303
      x391 = x262*x34
      x392 = x276*x50
      x393 = gamma_aa*x189
      x394 = x104*x357
      x395 = x196*x364
      x396 = 2.72568088924821d0*x157
      Ea = -rho_a*x81
      d1Ea(1) = -rho_a*(x100*x99 + x103*x77 + x170 + x27) - x81
      d1Ea(2) = rho_a*x232
      d1Ea(3) = -x250*x253
      d2Ea(1) = rho_a*(5.0d0*rho_a**(-2.0d0)*x101*x77 + x100*x258*x60*x9
     &7*( 0.478410284622892d0*x8*x95 + 0.458812622783553d0*x85 - 1.27576
     &075899438d0*x89)/x23**3 - 5.15926132639785d0*x105*x177*x3* x77 - 2
     &.75160604074552d0*x170*x259 - x254 - x257*x98*( 2.33889472482303d0
     &*x223*x88 - x255*(0.0407645339369707d0*rho_a**( -1.33333333333333d
     &0)*x1 + 0.00448671751316577d0*x109*x14 + x92) + 0.220008881071042d
     &0*x256*x3*x63*x82 - 1.60584417974243d0*x49*x82 + 0.458812622783553
     &d0*x84*x94 - 1.27576075899438d0*x87*x95) + x30 *(0.36240302520243d
     &0*gamma_aa*x106*x83 - 0.0133180320895522d0* rho_a**(-7.0d0)*x260*x
     &60 - x108*x261 - 1.46096495663704d0*x169* x263 + x261*(-0.804d0*x2
     &62 + 1.804d0) + x268*( -0.00291413479477612d0*x115 - 0.00144175546
     &132004d0*x117 - 0.00856659785039798d0*x120 + 0.188341686653414d0*x
     &126*x265 + 2.48756218905473d0*x135 + x139*x266 - 2.48756218905473d
     &0*x162 + 0.179350162766415d0*x166 - 0.502244497742438d0*x264) - x3
     &08*( 2.48756218905473d0*gamma_aa*x160*x285 - gamma_aa*x280*( 0.048
     &4078840501527d0*x269 + 0.0084375d0*x272) + 0.0131136065764925d0*rh
     &o_a**(-10.0d0)*x65 - 0.502244497742438d0* x126*x127*x275 + x128*x2
     &75*x279 + x131**2*x281*x283 + x136*x266* x306 - 2.28309273345556d0
     &*x139*x274 - x213*(x147*x290 + 0.0889588682240029d0*x274 + x291*x2
     &93 + 0.180246913580247d0*x296 + 0.180246913580247d0*x301) + 0.4675
     &7528851585d0*x270*x284 + 0.00456555896084678d0*x270 + 0.0128498967
     &75597d0*x272*x60 + 0.920781579194469d0*x274*x71 + x287*(-0.0097046
     &0380625487d0*x121 + x146*x286 + 0.0720987654320988d0*x159) + x305*
     &(x164*x290 + 4.0d0*x2*x293 + 0.987077852896471d0*x274 + 2.0d0*x296
     & + 2.0d0* x301)))) - x0*x254 - 7.5d0*x102*x77 - 2.0d0*x170 - 2.0d0
     &*x26
      d2Ea(2) = rho_a*(0.384641868836805d0*gamma_aa*x173*x309*x310 + x17
     &*x172*x176*x20* x7 - x175*x257*x309 + 1.37580302037276d0*x259*x30*
     &( 0.0453003781503037d0*x178 + x228*x307) - x30*( -0.00499426203358
     &209d0*gamma_aa*x256*x260 + 0.105700882350709d0* x107 - 0.730482478
     &31852d0*x168*x263*x322 + x268*x326 + x308*( -0.00437120219216418d0
     &*x114*x217 - x119*x324 - x122*x87 + x125* x329 - 1.24378109452736d
     &0*x134 + x140*x87 - 1.24378109452736d0* x161 - x213*(-x141 + x147*
     &x345 + x147*x346 + x347*x348 + 0.180246913580247d0*x352 + 0.180246
     &913580247d0*x355) - x221*x306 - 0.251122248871219d0*x265*x328*x60 
     &+ x280*(0.015286700226364d0* x116 + 0.005625d0*x119) - 0.175340733
     &193444d0*x284*x327 + x287* x337 + x305*(-x163 + x164*x345 + x164*x
     &346 + x347*x356 + 2.0d0* x352 + 2.0d0*x355) - 0.00144175546132004d
     &0*x327 + x329*(-x278 + x330 - 0.099435d0) + x335*x336 + x342*x343)
     &)) + x232
      d2Ea(3) = -rho_a*(x231*(0.000936424131296642d0*rho_a**(-5.0d0)*x26
     &0 + x193*x230*( 0.00109280054804105d0*gamma_aa*x62*x63 + x128*x274
     &*( -0.007768359375d0*x123 + x278 + 0.0497175d0) - x157*x213*(x291*
     & x359 + 0.180246913580247d0*x358 + 0.180246913580247d0*x362) + 2.4
     &8756218905473d0*x157*x304*(x164*x359 + x358 + x362) + x214 + x216 
     &+ 0.188341686653414d0*x274*x338 + 0.0657527749475415d0*x284* x49 -
     & x325*x342 + 1.24378109452736d0*x337*x340 - 2.48756218905473d0*x33
     &9) - x229*x267*x322*x326) + 0.0920083129740485d0*x105*x20**2*x310*
     &x83/mu**6)
      d2Ea(4) = -x251*(rho_a*x112*(x103*x373 - x78*(-x110*x373 - x113*( 
     &-0.00699626865671642d0*gamma_aa*x118*x133*x240 + 0.008566597850397
     &98d0*x118*x244 - 0.251122248871219d0*x126*x374 + 0.003498134328358
     &21d0*x131*x242*x283 + 0.00349813432835821d0*x160 *x243 - x213*x45*
     &(x238*x379 - x348*x377 + 0.180246913580247d0* x378 - 0.18024691358
     &0247d0*x381 - 0.136470991025459d0*x8) + x287* x45*(-0.072098765432
     &0988d0*x369 + x376) + x305*x45*(x233*x379 - x356*x377 + 2.0d0*x378
     & - 2.0d0*x381 - 1.51426716069345d0*x8) + x336*x372 + x343*x373 + 0
     &.0941708433267071d0*x374*x375*x64) + 5.45136177849642d0*x167*x28*x
     &34*x373*x75)) + x193*x368*x80)
      d2Ea(5) = x168*x231*x252*(-x125*x382 + x212*x389*(x147*x386 + x210
     &*x387 - x210* x388 - x238*x318) + 0.255849428582226d0*x220*x249 - 
     &x227*x250* x391 + 0.00938662444277524d0*x242 - 0.00383298875050529
     &d0*x243* x321 - x320*x384*x385 + x367*x384*x54 + x375*x382 - x383*
     &( -0.005625d0*x188 + 5.11766216345471d-5*x9) + x383*(-0.0028125d0*
     & x188 + 2.55883108172736d-5*x9) - x389*x390*(x164*x386 + x194*x387
     & - x194*x388 - x233*x318))
      d2Ea(6) = x253*(0.0229979325030318d0*x132*x392*x393 - 0.0153319550
     &020212d0*x185* x243*x367 - x212*x396*(-x371*x380 + 0.0734768142567
     &62d0*x394 + 0.163765189230551d0*x395) - 0.206370453055914d0*x223*x
     &277*x279 - 2.72568088924821d0*x234*x366*x385 + 6.78030071952291d0*
     &x368**2* x391 + x390*x396*(-x370*x380 + 0.815290678739414d0*x394 +
     & 1.81712059283214d0*x395) - 0.0281598733283257d0*x392*x60 - 2.1560
     &5617215923d-5*x271*x282*x393/tau_a**6)
      end subroutine
